Skip to main content

Posts

Showing posts from September 15, 2013

Use grep's --color option to make arguments pop in ps output

The Problem You would like to locate all purge processes that are running:

ps aux | grep purge

You'd specifically like to see the --dir= argument passed to each purge process. However, "ps aux" output is cluttered and the arguments are hard to locate with the human eye, especially if a lot of purge processes are running.
The Solution Output the entire --dir= argument in bold text via grep's --color option.
> ps aux|grep purge|grep --color -E '\-\-dir=[^ ]+'

root       861  0.0  0.0   8040  1356 ?        Ss   10:55   0:00 /bin/sh -c /usr/bin/nice /local/quantum/exec.sh --release-dir=/common/release --release-path=factory/purge -@- purge.pl --dir=/common/reporting --max-age='20 days' --max-uncompressed-age='10 days' --no-test --tee-path='/qnmlog/log/purge/reporting/$P' >/dev/null 2>&1 

root     31061  0.0  0.0   8040  1352 ?        Ss   16:00   0:00 /bin/sh -c /usr/bin/nice /local/quantum/exec.sh --release-dir=/common/release …