"ps -o" 和 "ps o" 之间的区别

Difference between "ps -o" and "ps o"

在脚本中,我试图检索 linux(RHEL 6.4 和 5.7)上当前用户的所有进程的一些详细信息。我正在使用 "ps -o pid,args,euser" 。但我意识到它不包括同一用户拥有但在不同 shell 会话中启动的进程。然后我尝试了 "ps o pid,args,euser",它有效。在手册页中,我看不到任何暗示这种差异的内容。是什么原因造成的?

$ ps  -o 'pid,args,euser'
  PID COMMAND                     EUSER
13491 -/usr/bin/ksh               ak
13519 bash                        ak
25427 ps -o pid,args,euser        ak

$ ps  o 'pid,args,euser'
  PID COMMAND                     EUSER
13491 -/usr/bin/ksh               ak
13519 bash                        ak
13699 -/usr/bin/ksh               ak
13727 bash                        ak
20573 -/usr/bin/ksh               ak
20616 bash                        ak
20996 -bash                       ak
21027 screen -D -R                ak
24842 /apps/ak/localdis/pub/cpyth ak
25460 ps o pid,args,euser         ak
25714 -/usr/bin/ksh               ak
25742 bash                        ak

我不是 100% 确定,但这可能是由于排序顺序和格式之间的歧义。

详情可见here:

O order Sorting order. (overloaded)

The BSD O option can act like -O (user-defined output format with some common fields predefined) or can be used to specify sort order. Heuristics are used to determine the behavior of this option. To ensure that the desired behavior is obtained (sorting or formatting), specify the option in some other way (e.g. with -O or --sort).

For sorting, obsolete BSD O option syntax is O[+|-]k1[,[+|-]k2[,...]]. It orders the processes listing according to the multilevel sort specified by the sequence of one-letter short keys k1, k2, ... described in the OBSOLETE SORT KEYS section below. The "+" is currently optional, merely re-iterating the default direction on a key, but may help to distinguish an O sort from an O format. The "-" reverses direction only on the key it precedes.

引用手册页(可通过 here Google 上的第一个结果获得)

  ... The use of BSD-style options will also change the process
  selection to include processes on other terminals (TTYs) that are owned
  by you; alternately, this may be described as setting the selection to
  be the set of all processes filtered to exclude processes owned by
  other users or not on a terminal. These effects are not considered when
  options are described as being "identical" below, so -M will be
  considered identical to Z and so on.