Linuxのシェルスクリプトが正しく動かない

実現したいこと

Linuxのシェルスクリプトを正しく動くようにしたい

発生している問題・分からないこと

引数の先頭文字が小文字なら
the '引数文字列' is lower case.

引数の先頭文字が大文字なら
the '引数文字列' is upper case.

と表示されるはずが、引数の先頭の文字が大文字でも「lower case」のほうが出力される

エラーメッセージ

error

1[root@localhost bashTest]# bash -x case.bash A 2+ case "$1" in 3+ echo 'the '\''A'\'' is lower case.' 4the 'A' is lower case. 5[root@localhost bashTest]# bash -x case.bash a 6+ case "$1" in 7+ echo 'the '\''a'\'' is lower case.' 8the 'a' is lower case. 9[root@localhost bashTest]# bash -x case.bash @ 10+ case "$1" in 11+ echo 'the '\''@'\'' is not alphabet' 12the '@' is not alphabet 13[root@localhost bashTest]#

該当のソースコード

bash

1 12 2 case "$1" in3 3 [a-z]*)4 4 echo "the '$1' is lower case."5 5 ;;6 6 [A-Z]*)7 7 echo "the '$1' is upper case."8 8 ;;9 9 *)10 10 echo "the '$1' is not alphabet"11 11 ;;12 12 esac

試したこと・調べたこと

上記の詳細・結果

bash -x case.bash A

sh -x case.bash A
を試したが両方とも「lower case」のほうが出力された

補足

centOS7

コメントを投稿

0 コメント