How To Wiki

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

1,795pages on
this wiki
Add New Page
Talk0 Share

command line arguments within a bash scripts

Example of a simple script:


#apply a function with a parameter
function apply
    echo "$request"

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

From HowTo Wiki, a Wikia wiki.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.