昨日举荐:每天学一个 Linux 命令(31):md5sum

命令简介

sort 对文件的文本内容排序。

零碎默认状况下,排序规定如下:

  • 以数字结尾的行,将排在以字母结尾的行后面
  • 以小写字母结尾的行,将排在以大写字母结尾的行后面
  • 按字母表的顺序排列以字母结尾的行

语法格局

sort [选项] [文件]sort [OPTION] [FILE]

选项阐明

-b    #排除结尾的空白-d    #只思考空白、字母、数字-f    #将小写字母视为大写字母思考-g    #依据数字排序-i    #排除不可打印字符-M    #按非月份的程序排序-h    #依据存储容量排序-n    #依据数字排序。-R    #随机排序-r    #倒序--sort=WORD    #依据指定的WORD排序-V   #按文本中(版本)数字的天然排序-o   #将排序后果写入一个文件--help     #显示帮忙信息并退出--version  #显示版本信息并退出

利用举例

[root@centos7 testdir]# cat cuttest.txt 1 2 3 4 5 6 89 8 7 6 5 4 32 1 9 8 7 6 5[root@centos7 testdir]# sort cuttest.txt1 2 3 4 5 6 82 1 9 8 7 6 59 8 7 6 5 4 3#将后果输入到文件[root@centos7 testdir]# sort -o sort.cut.txt cuttest.txt[root@centos7 testdir]# cat sort.cut.txt1 2 3 4 5 6 82 1 9 8 7 6 59 8 7 6 5 4 3#倒序排列[root@centos7 testdir]# sort -r cuttest.txt9 8 7 6 5 4 32 1 9 8 7 6 51 2 3 4 5 6 8

每天学一个 Linux 命令(29):tail

每天学一个 Linux 命令(30):cut