Monday, April 29, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 1161  / 2 Years ago, thu, january 13, 2022, 12:32:46

I am playing around with pipes to learn how to use them.
I am trying this command to kill a process by name: pgrep <some_process> | kill



but the output I am getting is the usage instruction for kill, like it didn't receive any input.



of course I know there are easier way to accomplish the same task like pkill or killall, but I want to know why is this not working.



Thank you


More From » command-line

 Answers
4

kill is not reading anything from stdin but expects some command line args and throws an error if it doesn't get them.



Piping only works if the program on the right side of the pipe is actually reading from the pipe. Not all programs do.


[#22568] Friday, January 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shionnky

Total Points: 276
Total Questions: 104
Total Answers: 108

Location: Montenegro
Member since Thu, Jun 16, 2022
2 Years ago
shionnky questions
;