2

I write below shell script to check whether given character is in uppercase or lowercase..

read d
case $d in
[a-z]) echo "Character is in Lowercase";;
[A-Z]) echo "Character is in Uppercase";;
esac

But when I enter any case in Uppercase it displays the output "charecter is in Lowercase" I just want to create simple script with basic programming. Is there any solution??

8
  • 1
    The script, as it stands now, works for me.
    – Kusalananda
    Aug 13, 2016 at 9:45
  • 1
    What do you mean by "when I enter any case in Uppercase"?
    – Kusalananda
    Aug 13, 2016 at 9:58
  • 1
    Iteresting. I always get lowercase in bash, but it works in dash, ksh, and zsh. Aug 13, 2016 at 10:03
  • 7
    Isn't it a matter of collation order? See for example Why does [A-Z] match lowercase letters in bash? Aug 13, 2016 at 10:29
  • 1
    See steeldriver's link. Insert as second line: LC_COLLATE=C
    – Cyrus
    Aug 13, 2016 at 11:10

0

Browse other questions tagged .