【linux学习笔记】 sort

来源:互联网 发布:网络通信加密系统 编辑:程序博客网 时间:2024/04/28 00:59

1.对用冒号:分隔的第二列升序排序:

Sort a colon delimited text file on 2nd field (employee_id):

$ sort -t: -k 2 employee.txt 



2.对IP地址排序:

参考1:http://cosy.univ-reims.fr/~bhaggar/doc/Linux-101-Hacks.pdf

参考2:http://www.madboa.com/geek/sort-addr/



 fields set apart from the others by a dot (-t .). Sort first by the first field, and only the first field (-k 1,1), then by the second and only the second (-k 2,2), and so on (-k 3,3 -k 4,4).