Bash Script with Arguments

Have you ever wondered to input the arguments in the bash scripts. Well there is the process how you do it.

Step 1: add the following script on the top of bash script file (

# passing the arguments

while [ $# -gt 0 ]; do

if [[ $1 == *”–“* ]]; then


declare $v=”$2″




echo $appName $version # this one is passed as an arguments

Step 2: pass the name of variable that you want to access in as an arguments something like this

./ –-appName App1 –-version v1.2

What a great way isn’t it?

2 thoughts on “Bash Script with Arguments

Leave a Reply

Your email address will not be published. Required fields are marked *