Is there a way to to evaluate a boolean expression and assign its value to a variable?
In most of the scripting languages there is way to evaluates e.g
//PHS
$found= $count > 0 ; //evaluates to a boolean values
I want similar way to evaluate in bash:
BOOL=[ "$PROCEED" -ne "y" ] ;
This is not working and tried other way but could not get a boolean value. IS there a way to
do this WITHOUT using IF ?
You could do:
If you’re working with
set -e, you can use instead:BOOLset to zero when there is a match, to act like typical Unix return codes. Looks a bit weird.This will not throw errors, and you’re sure
$BOOLwill be either 0 or 1 afterwards, whatever it contained before.