Linux Today: Linux News On Internet Time.

Positional Parameters in the Bash Shell

Jan 31, 2011, 21:05 (0 Talkback[s])

[ Thanks to Andrew Weber for this link. ]

"Special built-in environmental variables are positional parameters which hold command-line arguments to positions with the names 1,2,3,4, etc. which are indicated by $1,$2,$3,$4, etc. Argument $0 is the name of the script. These parameters are named positional because within the script the reference is to the position they occur on the command line.

"These positional variables can be used by a script. Those used typically are variables $0-$9 and $#. Once you have created a script and you name and execute the script you can begin using these positional parameters. For a script named param.sh, when you call the script you can follow the script name with variables. Here is an example:

"sh param.sh server mail"

Complete Story

Related Stories: