Ralph_Donnchadh
March 26th, 2009, 07:51 PM
Hello,
I am new to Ubuntu, and I am trying to write my first shell script.
I know in C++ I can use the following if-statment
// for some integers a and b
if (!( (a == 1) &&(b == 2)) )
{
// Do something
}
I also found out that in shell script I can use the following to achieve the same effect.
# for some integers a and b
if [ ! a -eq 1 ] || [! b -eq 2 ] # Difficult to read
then
# Do something
fi
However, in the shell script example, the condition statement is difficult to read. Is there any way in shell script to write the condition as:
(! (condition1 && condition2) )
to improve readability?
Thanks
I am new to Ubuntu, and I am trying to write my first shell script.
I know in C++ I can use the following if-statment
// for some integers a and b
if (!( (a == 1) &&(b == 2)) )
{
// Do something
}
I also found out that in shell script I can use the following to achieve the same effect.
# for some integers a and b
if [ ! a -eq 1 ] || [! b -eq 2 ] # Difficult to read
then
# Do something
fi
However, in the shell script example, the condition statement is difficult to read. Is there any way in shell script to write the condition as:
(! (condition1 && condition2) )
to improve readability?
Thanks