shell命令之tr

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Jayccccc_chao/article/details/85054182

先看看tr的帮助文档:

tr命令就是对标准输入进行翻译、压缩、删除等操作

举个栗子:

#!/usr/bin/env bash

#replace
echo "Hello Tr" |tr "HT" "ht"
# replace H to h,T to t.
#output hello tr

#squeeze
echo "Hello       Tr" |tr -s " "
#output Hello Tr

#delete
echo "Hello 123 tr" tr -d "13"
#output Hello 2 tr

#lower to upper
echo "hello tr" |tr [:lower:] [:upper:]
echo "hello tr" |tr 'a-z' 'A-Z'
#output HELLO TR

猜你喜欢

转载自blog.csdn.net/Jayccccc_chao/article/details/85054182