标签:
sort命令
[root@nfs-server test]# cat test.txt
10.0.0.9 a
10.0.0.8 k
10.0.0.7 f
10.0.0.7 n
10.0.0.8 c
10.0.0.8 z
10.0.0.9 o
[root@nfs-server test]# cut -d " "-f2 test.txt|sort -n ##-d后面跟分隔符为空格,-f指定第2列,然后通过sort排序
a
c
f
k
n
o
z
[root@nfs-server test]# awk -F ‘ ‘‘{print $2}‘ test.txt|sort -n
a
c
f
k
n
o
z
[root@nfs-server test]# sort -t " "-k2 test.txt
10.0.0.9 a
10.0.0.8 c
10.0.0.7 f
10.0.0.8 k
10.0.0.7 n
10.0.0.9 o
10.0.0.8 z
[root@nfs-server test]#
[root@nfs-server test]# sort -k2 test.txt
10.0.0.9 a
10.0.0.8 c
10.0.0.7 f
10.0.0.8 k
10.0.0.7 n
10.0.0.9 o
10.0.0.8 z
标签:
原文地址:http://www.cnblogs.com/hackerer/p/5364326.html