shell之sort

sort将文件进行排序,并将排序结果标准输出
基本语法: sort(选项)(参数)
选项
-n 按数值大小排序
-r 以相反顺序排序
-t 设置排序时用的分隔字符
-k 指定需要排序的列
参数
指定待排序的文件列表
案例

$cat sed.txt
a b 1
c d 8
e f 5 
g h 6
$sort -t " " -nk 3 sed.txt
a b 1
e f 5 
g h 6
c d 8
$sort -t " " -nrk 3 sed.txt
c d 8
g h 6
e f 5 
a b 1

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>