tr - translate or delete characters
删除或替换文字信息
参数:
-d 删除字符串
-s 删除重复的字符串只保留一个
[root@BASE ~]# cat c.txt
aa ccc
bbb bbbb
[root@BASE ~]# cat c.txt|tr -s " " //删除连续重复的空格只保留一个
aa ccc
bbb bbbb
[root@BASE ~]# cat c.txt|tr -s " ","a","c","b" //删除重复的空格,a,b,c只保留一个
a c
b b
[root@BASE ~]# cat c.txt|tr -s " " "k" //删除重复的空格只保留一个,并且将空格替换成“k”
aa
k
kccc
bbbkbbbb
[root@BASE ~]# cat c.txt|tr -d " " //删除空格
aa ccc
bbbbbbb
[root@BASE ~]# cat c.txt|tr -d "aaa" ccc
bbb bbbb
[root@BASE ~]# cat c.txt|tr -d "a" ccc
bbb bbbb
[root@BASE ~]#