Mat's Wiki

Bash

Conditionals

if [ expression ]
then
    command
fi

# or
if [ expression ]; then command; fi

You can use chaining of commands to simplify things

if [ -r ~/.profile ]; then
    source ~/.profile
fi

becomes

[ -r ~/.profile ] && . ~/.profile

or

init && configure && install && cleanup || echo Install failed

Resources

Search

Search the docs