本文共 1380 字,大约阅读时间需要 4 分钟。
格式:sort 选项 文件名
-r | 按降序排列 |
---|---|
-d | 按升序排列 |
-n | 按升序排列整数字段 |
-u | 按升序排列并删除连续重复行 |
[root@rzy ~]# cat aaa.txt 647853[root@rzy ~]# sort -r aaa.txt 876543
[root@rzy ~]# cat aaa.txt 647853[root@rzy ~]# sort -d aaa.txt 345678
[root@rzy ~]# cat aaa.txt 64478573[root@rzy ~]# sort -d aaa.txt 34457678[root@rzy ~]# sort -n aaa.txt 36784457
[root@rzy ~]# cat aaa.txt 394445167778[root@rzy ~]# sort -u aaa.txt 13456789
格式:uniq 选项 文件名
-c | 输出行出现次数 |
---|---|
-u | 删除连续重复行 |
[root@rzy ~]# cat aaa.txt 394445167778[root@rzy ~]# uniq -c aaa.txt 1 3 1 9 3 4 1 5 1 1 1 6 3 7 1 8
[root@rzy ~]# cat aaa.txt 394445167778[root@rzy ~]# uniq -u aaa.txt 395168
格式:cut 选项 文件名
-d | 指定分隔符,默认为空 |
---|---|
-f | 选择指定字段,-f1为第一个字段 |
-c | 输出字节数 |
[root@rzy ~]# cat aaa.txt a b c 目录[root@rzy ~]# cut -d' ' -f2 aaa.txt b
[root@rzy ~]# cat aaa.txt a b c 目录[root@rzy ~]# cut -f3 aaa.txt a b c 目录[root@rzy ~]# cut -d' ' -f4 aaa.txt 目录
[root@rzy ~]# cat aaa.txt a b c 目录[root@rzy ~]# cut -c1 aaa.txt a[root@rzy ~]# cut -c2 aaa.txt [root@rzy ~]# cut -c3 aaa.txt b[root@rzy ~]# cut -c4 aaa.txt [root@rzy ~]# cut -c5 aaa.txt c[root@rzy ~]# cut -c7 aaa.txt 目[root@rzy ~]# cut -c7,9 aaa.txt 目
转载地址:http://psbg.baihongyu.com/