bash - How to kill process by awk? -


in makefile have command

kill `ps aux | awk '/process_name/' | awk '$11 ~ /special_mask/ {print $2}'` 

it works through terminal when try call through command make my-command returns

kill `ps aux | awk '/process_name/' | awk '1 ~ /special_mask/ {print }'` 

and can't execute kill without process id. how fix it?

makefile needs double $$ shell commands.

you can use:

ps aux | awk '/[p]rocess_name/ && $$11 ~ /special_mask/{print $$2}' | xargs -r kill 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -