I'm trying to write an alias that will kill all running php processes.. this is the command i got in my ~/.bash_profile
alias killphp="ps aux | g [p]hp | awk '{print $3}' | xargs kill -9"
this command works just fine if i type it as is without the alias.. but if i simply run killphp
I get this weirdness:
grep: warning: recursive search of stdin
kill: illegal process id: (standard
kill: illegal process id: input):2:abdullah
kill: illegal process id: 10.9
kill: illegal process id: 0.2
kill: 2496576: No such process
kill: 20460: No such process
kill: illegal process id: ??
kill: illegal process id: S
kill: illegal process id: 7:14AM
kill: illegal process id: 0:00.28
kill: illegal process id: /usr/local/Cellar/php54/5.4.28/bin/php
kill: illegal process id: /Users/abdullah/dev/php/smartTaxi/app/console
kill: illegal process id: bcc:resque:worker-start
kill: illegal process id: -f
kill: illegal process id: request_queue
kill: illegal process id: --env=dev
kill: illegal process id: (standard
kill: illegal process id: input):3:abdullah
kill: illegal process id: 6.0
kill: illegal process id: 0.1
kill: 2486972: No such process
kill: 9708: No such process
kill: illegal process id: ??
kill: illegal process id: S
kill: illegal process id: 7:14AM
kill: illegal process id: 0:00.08
kill: illegal process id: php
kill: illegal process id: /Users/abdullah/dev/php/smartTaxi/app/../vendor/chrisboulton/php-resque/resque.php
if I run type killphp
I get this:
killphp is aliased to `ps aux | g [p]hp | awk '{print }' | xargs kill -9'
so apparently the $3
argument to awk is gone! how do I escape it? I tried doing /$3
and $$3
but none of them works.