|

楼主 |
发表于 2009-8-6 09:41:43
|
显示全部楼层
Post by biinn;2012132
没有awk,就用 cut:
- head -1 file | cut -d' ' -f1
复制代码
[xia@localhost ~]$ cat kk
29241 pts/2 00:00:00 bash
29362 pts/2 00:00:00 ps
[xia@localhost ~]$ head -1 kk | cut -d' ' -f1
29241
测试OK. 而且修改 -f1 to -f2
[xia@localhost ~]$ head -1 kk |cut -d' ' -f2
pts/2
但
[xia@localhost ~]$ head -1 kk |cut -d' ' -f3
没有想象的显示“00:00:00”,是因为 “pts/2” 后空格太多了。 该怎么解决? |
|