How do I check if a variable is in [A-Z]
I want something like this:
read var
while [ $var in [A-Z] ]
do
#code here
done
How to achieve this?
How do I check if a variable is in [A-Z] I want something like this:
How to achieve this? |
|||
add comment |
In bash, you can use a pattern on the right hand side of a
Turning off locale might be needed if you do not want |
|||
|
The simple one liner would be:
The full script would be:
|
||||
|
If you don't want to rely on Bash's regular expressions:
I'm guessing you want to use this for input validation. |
|||
|
$var
a single character or do you want to test that it contains only letters? – terdon Sep 26 '13 at 16:44