Case statement contain a list of options and will be different outcome depending on what the value of a variable

case $variable in
	1) echo "do something";; # or any command or variable
	s) echo "do s thing";;
	*) echo "do something when nothing match"
esac
  • case statement are wrapped in case and ends in esac
  • each case must end with ;; except for the last one
  • * means the case where none of the other options are matched

Arguments

echo output $1 $2
./script.sh one two
# output one two
  • $1,2,3 are positional arguments followed by one another, need to be entered when running the script
  • by default, even without arguments the script will run
  • $# is number of arguments a user is entered in the script