Posted by: Anonymous Coward
on December 15, 2005 09:10 AM
alias px='ps faxu ' alias pg='ps faxu | grep '
So, I type "pg privo" to list only the lines for privoxy. The grep proccess itself appears in the listing too, but it may be avoided by setting
alias pg='ps faxu | grep -v grep | grep '
Another option to exclude the grep process without calling it twice (from direct input or from a script) is to enclose in brackets the first character of the matching string:
$ ps faxu | grep [p]rivox
The next alias calls the above 'px' and uses the previous expression for grep.
alias pg2='function PSGREP { first="${1:0:1}" ; rest="${1:1}" ; eval px | grep [$first]"$rest" 2>/dev/null ; unset first rest ; } ; PSGREP ' $ pg2 sh $ pg2 "bin/sh<nobr> <wbr></nobr>/hom"
I don't like function and variables to stay written/modified for the current shell, so I prefer to use this grep trick from a bash script. If you don't care about it maybe you'll want to change their names to another ones that are not likely to have side effects on your CLI work, for example: PSGrep->Ii0sZhsL, first-> kKUhe8hys, rest->jxhNx2s
Two I use a lot: output of ps
Posted by: Anonymous Coward on December 15, 2005 09:10 AMalias pg='ps faxu | grep '
So, I type "pg privo" to list only the lines for privoxy. The grep proccess itself appears in the listing too, but it may be avoided by setting
alias pg='ps faxu | grep -v grep | grep '
Another option to exclude the grep process without calling it twice (from direct input or from a script) is to enclose in brackets the first character of the matching string:
$ ps faxu | grep [p]rivox
The next alias calls the above 'px' and uses the previous expression for grep.
alias pg2='function PSGREP { first="${1:0:1}" ; rest="${1:1}" ; eval px | grep [$first]"$rest" 2>/dev/null ; unset first rest ; } ; PSGREP '
$ pg2 sh
$ pg2 "bin/sh<nobr> <wbr></nobr>/hom"
I don't like function and variables to stay written/modified for the current shell, so I prefer to use this grep trick from a bash script. If you don't care about it maybe you'll want to change their names to another ones that are not likely to have side effects on your CLI work, for example: PSGrep->Ii0sZhsL, first-> kKUhe8hys, rest->jxhNx2s
Regards.
#