2011-01-07 33 views
0

在使用ps的bash shell中,是否可以返回进程名称+ PID而不使用它们的路径? 例如,使用PS-AI得到这样的:Bash shell,使用ps而不显示进程路径名称

Octo:~ decavolt$ ps -A 
PID TTY   TIME CMD 
1 ??  12:29.17 /sbin/launchd 
10 ??   0:01.37 /usr/libexec/kextd 
11 ??   7:03.37 /usr/sbin/DirectoryService 
12 ??  18:16.71 /usr/sbin/notifyd 
... 

我想看到的更像是:

PID TTY   TIME CMD 
1 ??  12:29.17 launchd 
10 ??   0:01.37 kextd 
11 ??   7:03.37 DirectoryService 
12 ??  18:16.71 notifyd 
... 

编辑:对不起,我应该澄清,这是上OSX 10.5和10.6

+0

在我的系统上,使用版本3.2.7,-A的输出与您正在查找的输出相同。 – Anders 2011-01-07 19:11:21

+0

对不起,安德斯,我应该提到,这是在OSX 10.5和10.6 – Jeff 2011-01-07 19:22:15

+0

更新我的答案。 – Anders 2011-01-07 19:25:07

回答

0

在我的系统上,ps -A做你想做的,但是,尝试ps -A c看看它是否适用于你(如果你使用的是GNU ps)。

0

尝试ps -o pid,tty,time,comm