tr命令可用于字符串的替换、压缩、删除
1、替换
echo one | tr 'a-z' 'A-Z'
输出:
ONE
2、压缩
连续重复字符以一个字符显示
echo 'nice to meet you' | tr -s ' '
输出:
nice to meet you
3、删除
echo 'nice 1324to 23m1234eet y3ou' | tr -d '0-9'
输出:
nice to meet you
tr命令可用于字符串的替换、压缩、删除
1、替换
echo one | tr 'a-z' 'A-Z'
输出:
ONE
2、压缩
连续重复字符以一个字符显示
echo 'nice to meet you' | tr -s ' '
输出:
nice to meet you
3、删除
echo 'nice 1324to 23m1234eet y3ou' | tr -d '0-9'
输出:
nice to meet you