-1

I have a command here:

ps aux | grep -i java | grep -i test | awk '{ print $2 }' 

which gives only one process id like 1201. Now I want to kill them by piping the 1201 to kill command.

How do I do that?

I tried tee like this:

ps aux | grep -i java | grep -i test | awk '{ print $2 }' | tee >(kill -9)

but that gives:

kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]

where I'm making mistake?

batman
  • 4,728
  • 8
  • 39
  • 45

1 Answers1

1

Use xargs to convert standard input to command-line parameters

ps aux | grep -i java | grep -i test | awk '{ print $2 }' | xargs kill
Raul Andres
  • 3,766
  • 15
  • 24