I am running this bash command:
xe pbd-unplug uuid=$PBDUUID
If the result exists - i.e. if the variable PBDUUID is not empty then I would like to run another command:
xe sr-forget uuid=$SRUUID
However, if the variable is blank then I would like print an error message
Error: No PBD.
and for the script to exit immediately (similar to sys.exit() in Python).
Is there a way to combine this if else then into one line? Also, what is the bash equivalent of sys.exit()?
Additional Information/Comment:
Regarding comment by Dilettant, yes that approach (if [ -z ${PBDUUID} ]; then) will also work. I was not aware of it. Thanks for this. That seems quite intuitive.