i have a command to kill some processes as below:
kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'`
the command works perfectly fine
>psu|grep MF1pp|grep -v grep|awk '{print $2}'
29390
29026
$>kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'`
$>psu|grep MF1pp|grep -v grep|awk '{print $2}'
when i create an alias as below and run it:
alias killaf="kill -9 `psu|grep MF1pp|grep -v grep|awk '{print $2}'`"
$> psu|grep MF1pp|grep -v grep|awk '{print $2}'
5487
5272
$>killaf
ksh: kill: bad argument count
gives the above error.
can anyone tell me what could be the issue?
The command line whereby you’re setting up the alias is not quoted correctly. Specifically, the back-quote embedded subcommand is being executed at the time you set up the alias, and not later when you actually want to run the alias.
Try setting it up this way:
edit: I fixed the quotes around the
awkcommand – it’s tricky to embed single-quotes when you’re already single-quoting.