Skip to content

sort

sort命令用于文本文件的排序。

下面是example.txt文件的内容。

bash
f
b
c
g
a
e
d
f
b
c
g
a
e
d

执行sort命令对其进行排序。

bash
$ sort example.txt
a
b
c
d
e
f
g
$ sort example.txt
a
b
c
d
e
f
g

参数

-R参数表示随机排序。

bash
sort -R example.txt
b
d
a
c
g
e
f
sort -R example.txt
b
d
a
c
g
e
f