Positional Parameter
noun
say it: “puh-ZISH-uh-nul puh-RAM-uh-ter” /pəˈzɪʃənəl pəˈræmətər/
A numbered variable, such as $1 or $2, that holds one of the words typed after a script's name when it runs.
What is a positional parameter in bash?
A positional parameter holds one of the words typed after a script's name, numbered by its place: $1 is the first, $2 the second and ${10} the tenth. $0 is the script's own name, $# counts the words, and "$@" hands on all of them, each in one piece.
echo "Happy birthday, $1! From $2" # a line in card.sh
./card.sh Maya Sam # Happy birthday, Maya! From Sam
In a sentence
- “The script checks $#, the number of positional parameters, before it does anything.”
- “In ./card.sh Maya Sam, the positional parameter $1 holds Maya.”
Level: Apprentice · More Unix terms at this level
Updated