I have a problem writing a test statement.
If I want to write [ $word = "t" (or) "I" ]
, meaning to test if the word is T
or t
how should I write it?
I have a problem writing a test statement.
If I want to write [ $word = "t" (or) "I" ]
, meaning to test if the word is T
or t
how should I write it?
Assuming you're using #!/bin/sh
for Bash scripting, here is a great resource: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
From Table 7-2. Combining expressions
at the above link:
[ EXPR1 -a EXPR2 ] True if both EXPR1 and EXPR2 are true.
[ EXPR1 -o EXPR2 ] True if either EXPR1 or EXPR2 is true.
You want the second one, so that would become:
[ $word == "t" -o $word == "T" ]