Solaris / SysV Style ps

Apr 27, '06 07:30:00AM

Contributed by: cronix

I come from a Solaris background, and my fingers can't seem to get used to typing ps -aux instead of ps -ef. So I wrote this script called ps-ef to save some sanity and format the ps output as close to Solaris style as I could. It will pass on any options to OS X's ps, so something like ps-ef -ww will work too. Just make it executable (chmod +x and put it somewhere in your path.

#!/bin/bash
pformat="user=UID,pid,ppid,cpu=C,start=STIME,tty,time,command"
psarglist=
psarglistlong=
while true ; do
        if [ -z "$1" ]; then
                break;
        fi
        optchar=${1:1}
        case $optchar in
                O|o|p|t|U)
                        shift
                        psarglistlong="$psarglistlong -$optchar $1"
                ;;
                *)
                        psarglist="$psarglist$optchar"
                ;;
        esac
        shift
done
ps -ax$psarglist $psarglistlong -o $pformat

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060421122857116