if

if

TLDR

Echo a different thing depending on a command's success

>_ [command] && echo "success" || echo "failure"
copy

Full if syntax

>_ if [condition]; then echo "true"; else echo "false"; fi
copy

List available if conditions

>_ help test
copy

Test if a given variable is empty

>_ if [[ -z $GIT_BRANCH ]]; then echo "true"; else echo "false"; fi
copy

Test if a file exists

>_ if [[ -e [filename] ]]; then echo "true"; else echo "false"; fi
copy

If directory not exists

>_ if [[ ! -d [path/to/directory] ]]; then echo "true"; else echo "false"; fi
copy

Copied to clipboard
free 100$ digital ocean credit