Bash shell,使用ps而不显示进程路径名

时间:2011-01-07 18:59:19

标签: bash ps

在使用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

3 个答案:

答案 0 :(得分:2)

http://ss64.com/osx/ps.html

根据此页面,-c选项应该是您正在寻找的。试试吧。

答案 1 :(得分:1)

在我的系统上,ps -A执行您想要的操作,但请尝试ps -A c查看它是否适合您(如果您使用的是GNU ps)。

答案 2 :(得分:0)

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