在使用ps的bash shell中,是否可以只返回进程名称+PID,而不返回它们的路径?例如,使用ps -A时,我会得到如下内容:
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上的
发布于 2011-01-08 03:17:51
试试ps -o pid,tty,time,comm。
https://stackoverflow.com/questions/4629192
复制相似问题