-   Linux - Newbie (
-   -   Send file output to 'kill' command (

jkarp2112 06-24-2008 11:49 PM

Send file output to 'kill' command
Would like to send the output of a text file, in this case a process id, to the 'kill' command so, well, that process would be kill'd ;)

example: if i 'cat' it outputs the process id i'd like to kill.

of course i could manually do this bit i would like to put it into a bash script.

much tia. - jeff

chrism01 06-25-2008 12:33 AM

kill $pid

or even

kill `cat`


use $() instead of backticks thus

pid=$(cat etc etc

bhert 06-25-2008 01:02 AM

I use the script below to kill 3 or 4 numbered process to kill the ones I spawn. Mostly I use it if firefox crashes.

I named the script bomb for fun and put it in my path.

If firefox acts funny, I just type bomb firefox and it's gone.

#script to kill process quickly

kill -9 `ps -e | grep "$*" | cut -d " " -f1` 2>/dev/null || kill -9 `ps -e | grep "$*" | cut -d " " -f2`


jkarp2112 06-25-2008 10:27 AM

Excellent - i'll use both to build my script!
thanks everyone, this really helped !!

solarkash 06-25-2008 05:17 PM

I'd prefer the xargs


cat | xargs kill

All times are GMT -5. The time now is 10:03 PM.