Felt I should collate useful stuff I constantly bounce between files to look up
Ctrl
+ Alt
+ e
(Ubuntu)
[[ "${MY_VAR}" == "" ]] && { echo "Some var was not set!"; exit 1; }
read -p "Something will happen, press y to continue: " -n 1 -r
echo # moves to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]] ; then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
FILE=/path/to/file
if [ ! -f $FILE ]; then
echo "File at $FILE does not exist, exiting"
exit 1
fi