tr
Last updated
echo "HELLO WORLD" | tr 'A-Z' 'a-z'
hello worldecho "hello 123 world 456" | tr -d '0-9'
hello worldcat text | tr '\t' ' 'echo aa.,a 1 b#$bb 2 c*/cc 3 ddd 4 | tr -d -c '0-9 \n'
1 2 3 4echo "thissss is a text linnnnnnne." | tr -s ' sn'
this is a text line.echo 1 2 3 4 5 6 7 8 9 | xargs -n1 | echo $[ $(tr '\n' '+') 0 ]cat file | tr -s "\r" "\n" > new_file
或
cat file | tr -d "\r" > new_file[:alnum:]:字母和数字
[:alpha:]:字母
[:cntrl:]:控制(非打印)字符
[:digit:]:数字
[:graph:]:图形字符
[:lower:]:小写字母
[:print:]:可打印字符
[:punct:]:标点符号
[:space:]:空白字符
[:upper:]:大写字母
[:xdigit:]:十六进制字符tr '[:lower:]' '[:upper:]'