is there a '?:' syntax shell script?
This might be a quickie... but i am not able to understand the appropriate thing to put in the google search...
Is there a way to use the ?: operator for if-else decision in a shell script? edit: the 'question mark - colon' operator (just editing so that its searchable by someone in need :-P) |
For those who don't already know, please tell us what that operator does.
In an "if" construct, the branching is based on whether a statement evaluates to TRUE or FALSE. Thus you can use any operator you want, as long as you wind up with something that produces a true or false output. Tell us what you are trying to do, and we can give better help.... |
Are you referring to the C-style clause:
Code:
var = (condition) ? return-value-if-true : return-value-if-false You can sort of emulate this behavior, like so: Code:
myvar=`[[ condition ]] && echo return-value-if-true || echo return-value-if-false` |
Quote:
and thanks a lot mate! Thats precisely what i needed |
All times are GMT -5. The time now is 10:19 AM. |