I have the following unix shell script, in which i have two integer
variables namely a and b.
If a is greater then or equal to b then shell script should exit with returning 0.
Else it should exit with returning 1.
if [ $a -ge $b ]
The shell puts the exit status of the last command in the variable
You could simply inspect it:
mycommand echo $?
... or you could use it to do something else depending on its value:
mycommand && echo "ok" || echo "failed"
or alternatively, and slightly more readable:
if mycommand; then # exit with 0 echo "ok" else # exit with non-zero echo "failed" if