, # Basic if statement , if $1 -gt 100 , then , echo Hey that\s a large number. , pwd , fi , date , , # Nested if statements , if $1 -gt 100 , then , echo Hey that\s a large number. , if (( $1 % 2 == 0 )) , then , echo And is also an even number. , fi , fi , , # else example , if $# -eq 1 , then , nl $1 , else , nl /dev/stdin , , # elif statements , if $1 -ge 18 , then , echo You may go to the party. , elif $2 == yes , then , echo You may go to the party but be back before midnight. , else , echo You may not go to the party. , fi , , # and example , if -r $1 && -s $1 , then , echo This file is useful. , fi , , # or example , if $USER == bob || $USER == andy , then , ls -alh , else , ls , , # case example , case $1 in , start) , echo starting , ;; , stop) , echo stoping , ;; , restart) , echo restarting , ;; , *) , echo don\t know , ;; , esac , , # Print a message about disk useage. , space_free=$( df -h | awk { print $5 } | sort -n | tail -n 1 | sed s/%// ) , case $space_free in , 1-5*) , echo Plenty of disk space available , ;; , 6-7*) , echo There could be a problem in the near future , ;; , 8*) , echo Maybe we should look at clearing out old files , ;; , 9*) , echo We could have a serious problem on our hands soon , ;; , *) , echo Something is not quite right here , ;; , esac , ,