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]#