Skip to content

Instantly share code, notes, and snippets.

@Neil-Smithline
Created May 29, 2012 00:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neil-Smithline/03984a57ffd87de7b060 to your computer and use it in GitHub Desktop.
Save Neil-Smithline/03984a57ffd87de7b060 to your computer and use it in GitHub Desktop.
Command to search for processes matching a regexp.
#!/bin/sh
FILTER=cat
if [ ${#} -gt 0 ]; then
FILTER="egrep -i $@"
fi
ps -wwAfm | egrep -v "^ *[0-9]* +$$ " | $FILTER
@Neil-Smithline
Copy link
Author

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 like procs, the egrep command will always come back as a match for whachamacallit. With procs, if there are no matching processes then you get no output. And the return value of egrep is actually meaningful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment