Hi
Does Unix have a conditional statement like Java as follows:
Condition ? Statement1 : Statement2
Thanks
Hi
Does Unix have a conditional statement like Java as follows:
Condition ? Statement1 : Statement2
Thanks
UNIX can run C, C++, Fortran, Java, Scripts, Perl, Python, Pascal, COBAL etc, so yes it can.
Sorry I meant shell script.
Basically, I want to do:
[ `echo "abcd" | cut -c1` = "a" ] && echo "a" ? echo "b"
Normally, it is a good idea or not to put a command in a test operation.
For instance, [ `echo "abcd" | cut -c1` = "a" ]
If not what else I can do.
Thank you
if ... then ... fi
case ... in ..... esac
all that a ? b : c does is if a then result is b else it's c.
I know about if or case statement. I am just wondering that i can make it short in one sentence like
[ `echo "abcd" | cut -c1` = "a" ] && echo "a" : echo "b"
By the way thanks so much
I am now assuming that there is not any.
If it's any consolation, "x ? y : z" almost didn't get into the Java language.
Basically it's not needed.
It's main advantage in C is for complex macro expansion such as va_arg etc.
[ `echo "abcd" | cut -c1` = "a" ] && echo "a" || echo "b"
[ "black" == "white" ] && echo yes || echo no