0

在使用 ps 的 bash shell 中,是否可以只返回进程名称 + PID 而没有它们的路径?例如,使用 ps -AI 得到如下结果:

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

4

3 回答 3

2

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

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

于 2011-01-07T19:09:16.713 回答
0

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

于 2011-01-07T19:14:22.703 回答
0

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

于 2011-01-07T19:17:50.987 回答