在bash當我鍵入ps -wef
我會得到:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 20:06 ? 00:00:01 /sbin/init
root 2 0 0 20:06 ? 00:00:00 [kthreadd]
root 3 2 0 20:06 ? 00:00:00 [ksoftirqd/0]
root 6 2 0 20:06 ? 00:00:00 [migration/0]
root 7 2 0 20:06 ? 00:00:02 [watchdog/0]
root 8 2 0 20:06 ? 00:00:00 [cpuset]
root 9 2 0 20:06 ? 00:00:00 [khelper]
root 10 2 0 20:06 ? 00:00:00 [kdevtmpfs]
root 11 2 0 20:06 ? 00:00:00 [netns]
root 12 2 0 20:06 ? 00:00:00 [sync_supers]
root 13 2 0 20:06 ? 00:00:00 [bdi-default]
root 14 2 0 20:06 ? 00:00:00 [kintegrityd]
root 15 2 0 20:06 ? 00:00:00 [kblockd]
root 16 2 0 20:06 ? 00:00:00 [ata_sff]
root 17 2 0 20:06 ? 00:00:00 [khubd]
root 18 2 0 20:06 ? 00:00:00 [md]
root 21 2 0 20:06 ? 00:00:00 [khungtaskd]
,我知道我想要的列保持,例如我想保持第二列是PID列,最後的結果將是:
1 2 3 6 7 8 9 10 11 12 13 14 15 16 17 18 21
PS的原始結果的第一行就會被刪除。
如何使用sed或awk來獲得我的最終結果?
謝謝。
謝謝!它很棒! –