How to execute different code depending on the command line arguments in a bash script

command line arguments within a bash scripts

Example of a simple script:


 * 1) !/bin/bash

function apply {   request=$1; echo "$request" }
 * 1) apply a function with a parameter

case $1 in    1)        #1) first code apply "first" ;;   2)        #2) second code apply "second" ;;   3)        #3) third code apply "third" ;;   *)	echo "bad argument"	;; esac
 * 1) the first argument

From HowTo Wiki, a Wikia wiki.