# 大小写转换示例代码

#!/bin/bash rm -rf ./6.4.1.txt echo "abcdEfgHiJ" > ./6.4.1.txt File=`cat ./6.4.1.txt` TmpFile=${File} echo "number of target:$#" [ $1 != "-u" ] && [ $1 != "-i" ] && { echo "please use'-u'or'-i'"; exit -1; } echo "source str:${File}" [ $1 == "-u" ] && { echo ${File} |tr "[a-z]" "[A-Z]"| tee -a ./6.4.1.txt; } [ $1 == "-i" ] && { echo ${File,,}| tee -a ./6.4.1.txt; } # the second way lower to upper #[ $1 == "-i" ] && { echo ${File^^}; }

 小写转大写

echo "abcd" |tr "[a-z]" "[A-Z]"

str="abcd"
echo ${str^^}

大写转小写

echo "abcd" |tr "[A-Z]" "[a-z]"
或
str="abcd"
echo ${str,,}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
相关资源
相似解决方案