我想從我的流程中獲得pid。我做ps aux | cut -d ' ' -f 2
但我注意到,有時它得到pid和有時沒有:如何總是從`ps aux`命令切斷PID?
[[email protected] ~]$ ps aux
user 2049 0.5 10.4 6059216 1623520 ? Sl date 8:48 process
user 12290 0.3 6.9 5881568 1086244 ? Sl date 2:30
[[email protected] ~]$ ps aux | cut -d ' ' -f 2
12290
[[email protected] ~]$ ps aux | cut -d ' ' -f 3
2049
通知第一cut
命令其輸送至2
而第二個是它管道到3
。如何從這些中挑選出PID而無需知道使用哪個號碼(2
或3
)?
有人可以告訴我這些以及爲什麼它拿起一個而不是其他的?