-
-
Save Neil-Smithline/03984a57ffd87de7b060 to your computer and use it in GitHub Desktop.
Command to search for processes matching a regexp.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FILTER=cat | |
if [ ${#} -gt 0 ]; then | |
FILTER="egrep -i $@" | |
fi | |
ps -wwAfm | egrep -v "^ *[0-9]* +$$ " | $FILTER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With no parameters, it will show all processes. Any parameters that are passed in will be used as an egrep regexp. The
procs
process will never be shown in the output.This is very helpful when you want to quickly see if some program
whatchamacallit
is running. Without a script likeprocs
, the egrep command will always come back as a match forwhachamacallit
. Withprocs
, if there are no matching processes then you get no output. And the return value of egrep is actually meaningful.