This is described in the "man" pages for Shells such as the Posix Shell and Korn Shell.
The single bracket version [ ] is a shorthand version of the unix "test" command and is described in outline terms in the Shell manual and in detail in "man test".
The double bracket version [[ ]] is a Conditional Expression and is described in that section of the Shell manual.
There is much overlap in basic syntax between the two. They have totally different syntax for boolean "and/or" conditions.
In your examples, both of them need mandatory double quotes round the string variable $z. Only the second example gave a syntax error, but both were wrong.
Beware that the "cut" will misbehave if there is one field in the data file but no commas. Try it.
Always put string variables in double quotes and you will have much less trouble with syntax.
Hi guys, I'm trying to run more than one "if" condition at once. What I want is something like
if ] or ] or ]; then
...
I can't remember the syntax for using this or/and set operators. Can someone please assist/ jog my memory?
thanks
Khoom (2 Replies)
This is the code:
while test 1 -eq 1
do
read a
$a
if test $a = stop
then
break
fi
done
I read a command on every loop an execute it.
I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test.
For example echo hello.
Now the... (1 Reply)
Hi All,
I have 2 variables. Result1 and Result2. I want to put a condition that if Both are True then echo "All True" Else Show Error.
Right now i am doing this and getting error.
if ;
then
echo "All True"
else
echo "Failed"
fi;
Error.
line 8: '
Solution: Looking for (2 Replies)
I really don't know the meaning of these operators. Could someone explain the meanings so I can make my test for today?
<, <=, ==, !=, >=, >,
||, &&, ! ~ , !~
Thanks! (1 Reply)
I do not know the use of the -o -v -R operators.
This is what the info says and I am confused of what optname and varname
mean, are they just normal variable?
-o optname
True if the shell option optname is enabled. See the list of
options under the ... (6 Replies)