I have noticed that | is used to send results of first command to the another. I would like to kill all processes that match a name.This is what pgrep normally does:$ pgrep name50895105And multiple arguments seem to work with kill:sudo kill 5089 5105But this is wrong:pgrep name | killSo how to do it properly?
Can I chain pgrep with kill?
shell;pipe;arguments
Try this:pgrep name | xargs killIf you use pgrep name | kill, the ouput of pgrep name is feed to stdin of kill. Because kill does not read arguments from stdin, so this will not work.Using xargs, it will build arguments for kill from stdin. Example:$ pgrep bash | xargs echo5514 22298 23079