How To Wiki
Advertisement

command line arguments within a bash scripts


Example of a simple script:

#!/bin/bash

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

#the first argument
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


From HowTo Wiki, a Wikia wiki.
Advertisement