默认情况下, sort 命令按照会话指定的默认语言的排序规则对文本文件中的数据行排序
[root@localhost hbk]# cat test.txt
one
two
three
four
five
six
经过sort排序后,可以看到根据字母顺序a-z排序的
[root@localhost hbk]# sort test.txt
five
four
one
six
three
two
若是数字,则使用-n参数
[root@localhost hbk]# cat file.txt
1
2
100
3
4
22
不加-n的情况,排序根据字符来排的,不是我们想要的
[root@localhost hbk]# sort file.txt
1
100
2
22
3
4
让文件数值大小排序
[root@localhost hbk]# sort -n file.txt
1
2
3
4
22
100
sort根据英文日期排序(实验失败)
[root@localhost hbk]# cat file2.txt
APR
AUG
DEC
FEB
JAN
JUL
JUN
MAR
MAY
NOV
OCT
SEP
加上-M参数,可以根据月份的顺序进行排序,在我本机测试是无效的,不知道为啥,感觉有问题。
[root@localhost hbk]# sort -M file2.txt
APR
AUG