BASH loewrcase and uppercase convert
- tr
echo "hello world" | tr 'a-z' 'A-Z'
or
echo "hello world" | tr '[:lower:]' '[:upper:]'
# [:alnum:]:字母和数字
# [:alpha:]:字母
# [:cntrl:]:控制(非打印)字符
# [:digit:]:数字
# [:graph:]:图形字符
# [:lower:]:小写字母
# [:print:]:可打印字符
# [:punct:]:标点符号
# [:space:]:空白字符
# [:upper:]:大写字母
# [:xdigit:]:十六进制字符
- 首字母转换
str1="lina"
echo ${str1^}
str2="LINA"
echo ${str2,}
- 全部转换
str1="lina"
echo ${str1^^}
str2="LINA"
echo ${str2,,}
- 大小写反转
str=Lina
echo ${str~~}