I am reading the ps man page and there is something I don't understand.
-f does full-format listing. This option can be combined with many other
UNIX-style options to add additional columns. It also causes the
command arguments to be printed. When used with -L, the NLWP (number of
threads) and LWP (thread ID) columns will be added. See the c option,
the format keyword args, and the format keyword comm.
I just want to add sid
to the output of ps -f
But I was confused by the following output, my understanding is -o
should just add sid
to the output of -f
but looks like -o
overwrites -f
completely.
I know I can specify all the options I want, like pid,ppid,pgid,sid,user,comm
etc etc but is there a way just add one additional column to output of -f
? That is what the man page says, correct ?
[njia@cst-cgxfile01 ~]$ ps -f
UID PID PPID C STIME TTY TIME CMD
njia 3397 26106 0 12:23 pts/1 00:00:00 ps -f
njia 26106 26105 0 09:45 pts/1 00:00:00 -bash
[njia@ ~]$ ps -f -o sid
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
SID
26106
26106
25875
25875
25875
25875
25875
[njia@ ~]$
In addition, ps -ef -o sid
will limit the process selection to those owned my me, that was a surprise as well.
ps -eO sid f
worked for me but that is even more wired. There are-f
in output format control andf
in output modifier. I can do thisps -f f
and it gives me all the fields included byps -f
but inps f
format. This becomes more interesting. – Ask and Learn Feb 11 '14 at 02:29ps ef sid,cmd
gives me a syntax error, do you meanps ef o sid,cmd
? – Ask and Learn Feb 11 '14 at 02:32ps
worked, and was documented, for the whole lifetime of procpsps
. The "BSD mode" nomenclature is an error perpetuated by the procps manual. https://unix.stackexchange.com/a/511530/5132 – JdeBP Jun 16 '20 at 09:57