tr命令用法
时间:2009-02-24 来源:linuxboy823
去除重复的字符
tr -s "[a-z]" < example.txt
cat example.txt | tr -s "[a-z]"
删除空行
cat example.txt | tr -s "[\n]"
cat example.txt | tr -s "[2]"
小写到大写
cat example.txt | tr "[a-z]" "[A-Z]"
cat example.txt | tr "[:lower:]" "[:upper:]"
大写到小写
与上例相反
Dos到Unix
cat example.txt | tr -s "[52]" "[2*]"
cat example.txt | tr -s "[\r2]" "[\n*]"
删除所有的tab代之以空格
cat example.txt | tr -s "[1]" "[0*]"
cat example.txt | tr -s "[\t]" "[0*]"
去除passwd的:以tab键代替增加可读性
cat /etc/passwd | tr -s "[:]" "[1]"
cat /etc/passwd | tr -s "[:]" "[\t]"
tr -s "[a-z]" < example.txt
cat example.txt | tr -s "[a-z]"
删除空行
cat example.txt | tr -s "[\n]"
cat example.txt | tr -s "[2]"
小写到大写
cat example.txt | tr "[a-z]" "[A-Z]"
cat example.txt | tr "[:lower:]" "[:upper:]"
大写到小写
与上例相反
Dos到Unix
cat example.txt | tr -s "[52]" "[2*]"
cat example.txt | tr -s "[\r2]" "[\n*]"
删除所有的tab代之以空格
cat example.txt | tr -s "[1]" "[0*]"
cat example.txt | tr -s "[\t]" "[0*]"
去除passwd的:以tab键代替增加可读性
cat /etc/passwd | tr -s "[:]" "[1]"
cat /etc/passwd | tr -s "[:]" "[\t]"
相关阅读 更多 +