开发者

Bash shell, using ps without displaying process path names

开发者 https://www.devze.com 2023-02-03 06:57 出处:网络
In a bash shell using ps, is it possible to return just process names + PIDs without their paths? For example, using ps -A I get something like this:

In a bash shell using ps, is it possible to return just process names + PIDs without their paths? For example, using ps -A I get something like this:

Octo:~ decavolt$ ps -A
PID TTY           TIME CMD
 1 ??        12:29.17 /sbin/launchd
10 ??         0:01.37 /u开发者_如何学Csr/libexec/kextd
11 ??         7:03.37 /usr/sbin/DirectoryService
12 ??        18:16.71 /usr/sbin/notifyd
...

What I'd like to see is more like:

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

EDIT: Sorry, I should have clarified that this is on OSX 10.5 and 10.6


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

According to this page, the -c option should be what you're looking for. Try that.


On my system, ps -A does what you want, however, try ps -A c to see if it works for you (if you're using GNU ps).


Try ps -o pid,tty,time,comm.

0

精彩评论

暂无评论...
验证码 换一张
取 消