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 9:31

>>3

In the first example, if the contents of program.pid is ``15'' you're saying kill 15. You're passing the contents as arguments, cat isn't writing to stdout.

kill does not read from stdin.

You're going to have to elaborate on this for me.  I mean, if cat doesn't write to stdout, then why do commands such as

cat somefile.txt | less
ls > filelist.txt && grep "cp" filelist.txt | rm -vf

work just fine?

Also, call me a faggot if you must, but how did you put the word "kill" in a fixed-width font?

I mean, if the pid of the process I want to kill is "15", and I can kill it by typing "kill 15", why can't I cat program.pid | kill if it's the same as typing "kill 15"?

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