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
Post a Comment