Linux中的sort排序
来源:互联网 发布:ubuntu怎么分区 编辑:程序博客网 时间:2024/04/30 20:13
默认排序
sort filename
[root@localhost ~]$ cat test.txt eeebbbdddaaaccc[root@localhost ~]$ sort test.txt aaabbbcccdddeee
去除重复行
sort -u filename
[root@localhost ~]$ cat test.txt eeebbbddddddaaaccc[root@localhost ~]$ sort -u test.txt aaabbbcccdddeee
按列排序
sort -k 2 filename 按第二列排序
[root@localhost ~]$ cat test2.txt eee 23 555ddd 11 666aaa 22 888ccc 23 111bbb 24 222[root@localhost ~]$ sort test2.txt aaa 22 888bbb 24 222ccc 23 111ddd 11 666eee 23 555[root@localhost ~]$ sort -k 2 test2.txt ddd 11 666aaa 22 888ccc 23 111eee 23 555bbb 24 222[root@localhost ~]$ sort -k 3 test2.txt ccc 23 111bbb 24 222eee 23 555ddd 11 666aaa 22 888
指定分隔符
sort -t : filename
[root@localhost ~]$ cat test2.txt eee:23:555ddd:11:666aaa:22:888ccc:23:111bbb:24:222[root@localhost ~]$ sort -t : -k 2 test2.txt ddd:11:666aaa:22:888ccc:23:111eee:23:555bbb:24:222
逆序排列
sort -r filename
[root@localhost ~]$ cat test.txt eeebbbdddaaaccc[root@localhost ~]$ sort -r test.txt eeedddcccbbbaaa
按数字排序
sort -n filename
[root@localhost ~]$ cat test3.txt 1021134[root@localhost ~]$ sort test3.txt 1011234[root@localhost ~]$ sort -n test3.txt 2101134
参考
- Linux sort命令
- 《sort帮你排序》-linux命令五分钟系列之二十六
- GNU sort - What is the default algorithm used for comparison?
0 0
- Linux中的sort排序
- linux内核中的排序接口--sort函数
- linux中的统计、排序之sort
- STL中的sort排序
- C#中的 sort排序
- JAVA中的sort排序
- lua中的sort排序
- JavaScript中的sort排序
- linux下排序sort
- Linux sort命令排序
- Linux-sort排序
- linux中的sort命令
- Linux 中的 sort 命令
- Linux中的sort详解
- JavaScript中的排序函数sort
- java中的Collections.sort排序
- 看懂STL中的sort排序
- JavaScript中的sort排序问题
- Android 6.0 miracast 学习
- tarjan算法求解强连通分量
- python中的staticmethod
- 关于“TCP segment of a reassembled PDU”
- [安全]
- Linux中的sort排序
- 手机上app测试总结
- Python main函数
- [BZOJ 3784][树上的路径][点分治+堆]
- codefroces767D 二分答案
- Excel2016 四个超强的数据分析功能
- wpf 输入字符长度限制
- Qt——应用程序打包(一)
- 从数据库角度描述CPU、内存、硬盘三者关系