tee 命令
tee 命令后面跟文件名,其作用类似于重定向 > ,但它比重定向多一个功能,即把文件写入后面所跟的文件时,还显示在屏幕上。该命令常用于管道符 | 后
之前接触过重定向 >
[root@evan-01 ~]# echo '666' > a.txt
[root@evan-01 ~]# cat a.txt
666
[root@evan-01 ~]#
可以把内容写入到 a.txt 里,但是如果不 cat 看不到写进去的内容
tee
先清空 a.txt,把文件写入到后面的文件,而且还显示在屏幕上。tee 要写在管道符 | 后面
[root@evan-01 ~]# > a.txt
[root@evan-01 ~]# echo '666' | tee a.txt
666
[root@evan-01 ~]#
-a 追加
[root@evan-01 ~]# echo '888' | tee -a a.txt
888
[root@evan-01 ~]# cat a.txt
666
888
[root@evan-01 ~]#
tr 命令
tr 命令用于替换字符,常用来处理文档中出现的特殊符号,如 DOS 文档中出现的符号 ^M
选项 | 含义 |
---|---|
-d | 表示删除某个字符,后面跟要删除的字符 |
-s | 表示删除重复的字符 |
替换一个字符
[root@evan-01 ~]# echo "evanlinux" | tr 'e' 'E'
Evanlinux
[root@evan-01 ~]#
替换多个字符
[root@evan-01 ~]# echo "evanlinux" | tr '[el]' '[EL]'
EvanLinux
[root@evan-01 ~]#
[a-z] 替换成 [A-Z]
[root@evan-01 ~]# echo "evanlinux"
evanlinux
[root@evan-01 ~]# echo "evanlinux" | tr '[a-z]' '[A-Z]'
EVANLINUX
[root@evan-01 ~]#
split 命令
split 命令用于切割文档
选项 | 含义 |
---|---|
-b | 表示依据大小来分割文档,默认单位为 byte |
-l | 表示依据行数来分割文档 |
依据大小分割
[root@evan-01 ~]# mkdir testdir
[root@evan-01 ~]# cd testdir
[root@evan-01 testdir]# ls
[root@evan-01 testdir]# cp /etc/passwd ./
[root@evan-01 testdir]# split -b 500 passwd
[root@evan-01 testdir]# ls
passwd xaa xab xac
[root@evan-01 testdir]#
如果不指定目标文件名,就会按照 xaa、xab … 这样的文件名来存取切割后的文件。当然我们也可以指定文件名
查看大小
[root@evan-01 testdir]# du -sh *
4.0K passwd
4.0K xaa
4.0K xab
4.0K xac
[root@evan-01 testdir]#
指定文件名依据大小分割
[root@evan-01 testdir]# rm -rf xa*
[root@evan-01 testdir]# split -b 500 passwd 123
[root@evan-01 testdir]# ls
123aa 123ab 123ac passwd
[root@evan-01 testdir]#
依据行数分割
[root@evan-01 testdir]# wc -l passwd
28 passwd
[root@evan-01 testdir]# split -l 4 passwd
[root@evan-01 testdir]# ls
123aa 123ab 123ac passwd xaa xab xac xad xae xaf xag
[root@evan-01 testdir]# wc -l *
12 123aa
10 123ab
6 123ac
28 passwd
4 xaa
4 xab
4 xac
4 xad
4 xae
4 xaf
4 xag
84 total
[root@evan-01 testdir]#