1、cut:用来提取文件的片段
-d 后面指定分隔的符号
-f 指定显示第几列
-c 后面跟显示的字符1-n,character
-b 后面根据显示的字节,byte
kdvmt@kdvmt:temp$ cat 2.txt | cut -b 1-6
hello
name y
leaf c
kdvmt@kdvmt:temp$ cat 2.txt | cut -c 1-5
hello
name
leaf
kdvmt@kdvmt:temp$ cat 2.txt
hello dog, hello cat
name you duplictae
leaf cup telephone
#根据空格进行分割
kdvmt@kdvmt:temp$ cat 2.txt | cut -d ' ' -f 1
hello
name
leaf
#根据逗号进行分割
kdvmt@kdvmt:temp$ cat 2.txt | cut -d ',' -f 1
hello dog
name you duplictae
leaf cup telephone
kdvmt@kdvmt:temp$ cat 2.txt | cut -d ',' -f 2
hello cat
name you duplictae
leaf cup telephone
2、sort 用于对文本进行排序,默认是升序排列
-r:reverse 降序排列
-c:count 列出某一行出现的次数
kdvmt@kdvmt:temp$ sort 2.txt
hello dog, hello cat
leaf cup telephone
name you duplictae
kdvmt@kdvmt:temp$ sort -r 2.txt
name you duplictae
leaf cup telephone
hello dog, hello cat
3、paste 对多文本进行合并,行合并
用-d指定分隔符,默认是tab
kdvmt@kdvmt:temp$ cat 1.txt
hello
good
town
kdvmt@kdvmt:temp$ cat 2.txt
world
morning
down
kdvmt@kdvmt:temp$ paste 1.txt 2.txt > 3.txt
kdvmt@kdvmt:temp$ cat 3.txt
hello world
good morning
town down
kdvmt@kdvmt:temp$ paste 1.txt 2.txt -d ':' > 3.txt
kdvmt@kdvmt:temp$ cat 3.txt
hello:world
good:morning
town:down
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)