> does the man page show a '-o' or a '-F' option for 'ps' ???
Tony,
Unfortunately, no. The only args seem to be:
ps [-edaflP] [-u ulist] [-g glist] [-p plist] [-t tlist] [-R prmgroup]
The XPG4 environment has a few more such as [-C cmdlist] and [-o
format], but that doesn't really
help. The first post replay using the 'match' does work for my needs,
however, since I don't have the ':' character being used in any of my
processes. Many thanks to Chuck Dillon and the rest who
have contributed to this thread so far.
Carl
> >Unix flavor is HP-UX 11.0.
> >Carl
> does the man page show a '-o' or a '-F' option for 'ps' ???
> -tony
> >> >> > > ps -ef | grep process_name | grep -v grep |
> >> >> > > awk '{ if (match($8,".*:.*") == 0) print $8;else print $9; }'
> >> >> >You could also use cut since the column position is the same regardless
> >> >> >of which format is used for the date. Or your ps might let you be more
> >> >> >specific about which fields you actually intend to use.
> >> >> Sure and you could use sed to remove all forms of the STIME column and
> >> >> print $7.
> >> >> I avoid using cut in that way, IOW assuming nothing will shift even
> >> >> one char, that is too fragile for my taste.
> >> >This is an excellent point. Notice that your damned either way; if a
> >> >process had a colon anywhere in the command, your solution would match
> >> >on it, too. Sometimes its quite difficult to know which way is more
> >> >prone to breaking ...
> >> Did the original poster ever say which version of *nix was being used???
> >> I ask because on AIX there is the '-F' option... and on Sun (and in
> >> POSIX-98) there is the '-o' option...
> >> Both of these options allow you to specify which 'ps fields' are
> >> displayed and in what order you want them displayed...
> >> ...in which case you could specify the 'CMD' to appear first, the 'pid'
> >> next, etc..... That way your 'awk could grab the first field '$1'...
> >> Unfortunately, linux doesn't have that option... (at least not in
> >> RedHat5.2...the only versions available to me)
> >> HTH,
> >> -tony
> >> --
> --