Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux shell: How to read command argument from a file?

Tags:

linux

pipe

xargs

I have process id in a file "pid" I'd like to kill it.

Something like:

kill -9 <read pid from file>

I tried:

kill -9 `more pid` 

but it does not work. I also tried xargs but can't get my head around it.

like image 466
Igor Katkov Avatar asked Nov 10 '09 22:11

Igor Katkov


2 Answers

Does

kill -9 $(cat pid)

work for you?

like image 184
sdtom Avatar answered Sep 24 '22 02:09

sdtom


Let me summarize all answers

kill -9 $(cat pid)
kill -9 `cat pid`
cat pid | xargs kill -9
like image 44
Igor Katkov Avatar answered Sep 24 '22 02:09

Igor Katkov