Setting alias (quotes, acutes)

Hello,
I'd like to have an alias to view some processes sorted:

I have:

ps -ef | grep pmon | awk -F" " '{ print $8" "$0 }' | sort | cut -d" " -f2- | grep -v "grep pmon"

It doesn't work, however, if I put it as alias because on acutes insize awk:

alias pmon='ps -ef | grep pmon | awk -F" " '{ print $8" "$0 }' | sort | cut -d" " -f2- | grep -v "grep pmon"'

Any suggestions?

How about

alias pmon='ps -ef | grep [p]mon | sort -k8,8'
1 Like

I see your Three and raise you One:

alias pmon='ps -f --sort cmd -C pmon'

This only works if you have Gnu ps . The --sort option takes the standard output format identifiers; the -C option selects the processes you wish to view.

Andrew

Otherwise, the way to insert a single quote inside single quotes is this ugly thing:

$ echo 'string'"'"'string'
string'string
$

Lovely - works with procps-ng version 3.3.10 as well. BUT - you need to specify the unabridged command name; it won't accept any wild cards nor regexes as far as I can see...