我找到解決方案,但它不工作http://www.cyberciti.biz/faq/linux-unix-shell-programming-converting-lowercase-uppercase/小寫大寫轉換
[[email protected] tmp]# y="this Is A test"
[[email protected] tmp]# echo "${y^^}"
-bash: ${y^^}: bad substitution
我找到解決方案,但它不工作http://www.cyberciti.biz/faq/linux-unix-shell-programming-converting-lowercase-uppercase/小寫大寫轉換
[[email protected] tmp]# y="this Is A test"
[[email protected] tmp]# echo "${y^^}"
-bash: ${y^^}: bad substitution
您可以使用下面的代碼中的任何一個:
$ tr '[:lower:]' '[:upper:]' <input.txt> output.txt
或
$ sed -e 's/\(.*\)/\U\1/' input.txt > output.txt
sed表單不是非常便攜的(AFAIK它是GNU sed特有的)。便攜式sed版本將是'sed -e'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ /'input.txt> output.txt'。 –
@ user1598202 - +1:很好的回覆! – paulsm4
'y =「這是一個測試」; y = $ {echo $ y | tr「a-z」「A-Z」}'; echo y:$ y' – paulsm4