I’m trying to regex process id’s based on parts of a process name. It seems to work if I only do a single word, but it fails when I try to do something like: find me any process with path /beginning ** /endswiththis/
Here’s what I have so far:
QUEUE_PID="$(ps -ef | grep endswiththis | grep -v $0 | grep -v grep | awk '{ print $2 }')";
Any thoughts?
Thanks,
Steve
Many UNIXes now have
pgrepwhich does exactly what you wantAs an example:
The parameter passed to
pgrepis a regular expression – this is matched against either against the executable file name or the full process argument string dependent on parameters (-f).For more information