Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

piping stdout of cat to kill's stdin

Name: Anonymous 2008-01-29 23:52

If I have the pid of some process stored in a text file, let's call it program.pid, and I want to end that process via the kill command, how come I can't do this:

bash:$ cat program.pid | kill

But if cat program.pid, and just type the output into the kill command, it works and I stop the process.  Why can't I pipe the output from cat to kill?

Name: Anonymous 2008-02-01 23:29

>>11
You have a bunch of commands called filters that read from stdin.  less is one of them.  kill is not.

You can usually only use | with filter type commands.  Further examples: more, tr, col, grep, sort

Some commands can act as both.  Usually you have to put a - instead of the file name to get it to read from stdin, or in tar's case, specify the f option to make it NOT read from stdin.

>>2
`this` makes the Bash shell replace whatever is inside the ` marks with the stdout of that command.  Very useful.  Example: echo `/bin/date`.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List