正常的ps命令是打印出来PID TTY TIME CMD四个字段

  PID TTY           TIME CMD
 5131 ttys000    0:00.20 -zsh
14330 ttys000    0:00.46 ios_webkit_debug_proxy -f chrome-devtools://devtools/b
60457 ttys001    0:00.31 -zsh
 7097 ttys002    0:00.14 -zsh
88776 ttys003    0:00.22 -zsh
 4748 ttys004    0:07.38 /Library/Frameworks/Python.framework/Versions/3.8/Reso
76131 ttys004    0:00.59 -zsh
16212 ttys005    0:00.24 -zsh
42452 ttys005    0:03.67 /usr/bin/java -jar UICrawler-2.0.jar -u d4917fbadf4b71
28402 ttys006    0:00.28 -zsh
43381 ttys009    0:00.15 -zsh

看到挺诡异的没,CMD内容过长被截断了,UICrawler这一行本身很长,如何显示出完整的路径呢,ps -f 打印出完整信息(后来发现这个把终端宽度拖宽一点就可以显示了,他只是一行显示不下不回换行,害我弄好久,垃圾,ps -f默认应该是可以多行显示)

 ps -f
  UID   PID  PPID   C STIME   TTY           TIME CMD
  501  5131  5130   0 10:02上午 ttys000    0:00.20 -zsh
  501 14330  5131   0 10:17上午 ttys000    0:00.48 ios_webkit_debug_proxy -f chrome-devtools://devtools/bundled/inspector.html
  501 60457 60456   0 四10上午 ttys001    0:00.31 -zsh
  501 88776 88775   0 12:27下午 ttys003    0:00.22 -zsh
  501  4748 76131   0 10:01上午 ttys004    0:07.53 /Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python ocrServer.py
  501 76131 76130   0  4:36下午 ttys004    0:00.59 -zsh
  501 16212 16211   0 10:19上午 ttys005    0:00.24 -zsh
  501 47021 16212   0  2:30下午 ttys005    0:04.07 /usr/bin/java -jar UICrawler-2.0.jar -u d4917fbadf4b71db3c9b3a835f100099b0432442 -s 127.0.0.1 -t 4723 -f config_ios.yml -b com.tencent.weread -o out_file -log
  501 48459 47021   0  2:33下午 ttys005    0:00.01 /usr/local/bin/idevicescreenshot -u d4917fbadf4b71db3c9b3a835f100099b0432442 out_file/del.png
  501 43381 43380   0  2:24下午 ttys009    0:00.18 -zsh

内容是齐全了,怎么才能把除了CMD字段的其他内容去掉ps -fo command?

ijm@172-10-20-5 ~ % ps -fo command
  UID   PID  PPID   C STIME   TTY           TIME CMD              COMMAND
  501  5131  5130   0 10:02上午 ttys000    0:00.20 -zsh             -zsh
  501 14330  5131   0 10:17上午 ttys000    0:00.49 ios_webkit_debug ios_webkit_debug_proxy -f chrome-devtools://devtools/bundled/inspector.html
  501 60457 60456   0 四10上午 ttys001    0:00.31 -zsh             -zsh
  501 52840 52839   0  2:40下午 ttys002    0:00.15 -zsh             -zsh
  501 88776 88775   0 12:27下午 ttys003    0:00.22 -zsh             -zsh
  501  4748 76131   0 10:01上午 ttys004    0:07.66 /Library/Framewo /Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python ocrServer.py
  501 76131 76130   0  4:36下午 ttys004    0:00.59 -zsh             -zsh
  501 16212 16211   0 10:19上午 ttys005    0:00.24 -zsh             -zsh
  501 50840 16212   0  2:38下午 ttys005    0:03.91 /usr/bin/java -j /usr/bin/java -jar UICrawler-2.0.jar -u d4917fbadf4b71db3c9b3a835f100099b0432442 -s 127.0.0.1 -t 4723 -f config_ios.yml -b com.tencent.weread -o out_file -log

不行啊-f会把所有的字段显示出来,后来搜索ps -o command

ijm@172-10-20-5 ~ % ps -o command
COMMAND
-zsh
ios_webkit_debug_proxy -f chrome-devtools://devtools/bundled/inspector.html
-zsh
-zsh
-zsh
/Library/Frameworks/Python.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python ocrServer.py
-zsh
-zsh
/usr/bin/java -jar UICrawler-2.0.jar -u d4917fbadf4b71db3c9b3a835f100099b0432442 -s 127.0.0.1 -t 4723 -f config_ios.yml -b com.tencent.weread -o out_file -log

这里只会展示终端启动的一些进程,没有终端的进程是显示不出来.命令-A或-e解决这个问题ps -Ao command或ps -eo command
最终命令我要搜索UICrawler进程:
ps -Ao command |grep UICrawler

ijm@172-10-20-5 ~ % ps -Ao command |grep UICrawler
grep UICrawler
/usr/bin/java -jar UICrawler-2.0.jar -u d4917fbadf4b71db3c9b3a835f100099b0432442 -s 127.0.0.1 -t 4723 -f config_ios.yml -b com.tencent.weread -o out_file -log
03-05 23:49