It has been annoying from time to time when I switch to support non-linux platform, especially and mostly on AIX. I love to use pgrep to shorten a ps command to find out PID (process ID), that has never existed on AIX.
This script is very simple to use of pgrep and placed on /usr/local/bin or wherever you set an environment variable PATH.
# pgrep alike while [ $# -gt 0 ] do #echo "$1" if [[ "$1" != "-"* ]]; then break; fi shift done ps -o pid,args -e|grep "$1" |grep -v grep
Here is the output example from my AIX platform
[oracle@host01 ~]$ pgrep -lf pmon 9699392 asm_pmon_+ASM 14680280 ora_pmon_cdb 18088032 ora_pmon_emrep
In summary, this script will ignore an option starting with – (minus), and use another as pattern searching on grep command.