以:作为分隔符,用第3列从小到大排序
[root@localhost ~]# sort -t: -k3 -n /etc/passwd
以:作为分隔符,用第3列从大到小排序
[root@localhost ~]# sort -t: -k3 -nr /etc/passwd
重复的行只显示一次
[root@localhost ~]# sort -u 2.txt
统计文档有多少行
[root@localhost ~]# wc -l 1.txt
以空格作为分隔符,统计字符串数量
[root@localhost ~]# wc -w 1.txt
统计字符数量,包含换行符$
[root@localhost ~]# wc -m 1.txt
去除文档中相邻的重复行,不相邻行不被视作重复
[root@localhost ~]# uniq 1.txt
由于以上操作,不相邻行不被视作重复,所以一般会在前面加上sort,uniq加参数-c表示统计重复行出现的次数
[root@localhost ~]# sort 1.txt | uniq -c
把内容覆盖重定向到1.txt
[root@localhost ~]# echo "test1" | tee 1.txt
把内容追加重定向到2.txt
[root@localhost ~]# echo "test1" | tee -a 1.txt
把小写t换成大写T
[root@localhost ~]# echo "test1" | tr 't' 'T'
把小写ts换成大写TS
[root@localhost ~]# echo "test2" | tr 'ts' 'TS'
把所有小写替换成大写
[root@localhost ~]# echo "test3" | tr 'a-z' 'A-Z'
把1.txt分割为每10m一个小文件,默认单位是b,以new1_为所有文件的前缀
[root@localhost ~]# split -b 10m 1.txt new1_
把2.txt分割为每100行一个小文件,以new2_为所有文件名前缀
[root@localhost ~]# split -l 100 2.txt new2_