【linux学习笔记】 sort

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

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

$ sort -t: -k 2 employee.txt 

【linux学习笔记】 sort_第1张图片


2.对IP地址排序:

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

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

【linux学习笔记】 sort_第2张图片


 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).


你可能感兴趣的:(【linux学习笔记】 sort)