#!/bin/sh ps -axo pid,command,args | grep -i "$@" | awk '{ print $1 }'
This yields the output you're used to:
foo:~$ pgrep postgres 2853 2856 2857 2858 2859 3057 3059
I like to see the full process args with that. A slight tweak:
#!/bin/sh pids=`ps -axo pid,command,args | grep -i "$@" | awk '{ print $1 }' | tr '\n' ','` ps -p $pids -o pid,args
Gives you:
foo:~$ pgrep postgres PID ARGS 2853 /opt/lib/postgresql84/bin/postgres -D /opt/var/db/postgresql84/d 2856 postgres: writer process 2857 postgres: wal writer process 2858 postgres: autovacuum launcher process 2859 postgres: stats collector process 3166 /bin/sh /Users/imfeldma/bin/pgrep postgres
Nothing stops you from replacing ps with kill to obtain a poor mans pkill. Enjoy.
UPDATE: Of course you may also install proctools via MacPorts or directly from Sourceforge: http://sourceforge.net/projects/proctools/