special-parameter
Bash positional parameters — $1 through ${N}
Arguments supplied to a script or function are accessible by position. set -- replaces the current positional arguments; shift removes leading ones. Braces are necessary for multi-digit indexes: $10 is $1 followed by literal 0. Use "$@" to forward all arguments; ${N} in the syntax notation means a literal index, not an indirect variable lookup. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): [one item] [ten] [one item0].
Formal Syntax & Structure
bash syntaxbash
$1 … $9; ${10}; ${N} (N is a literal decimal index)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| N | literal decimal index | Positive argument position. |
Return Value
string
Argument at the requested position; unset if absent (nounset can reject expansion).
Working Example
Example Snippetbash
set -- 'one item' 2 3 4 5 6 7 8 9 tenprintf '[%s] [%s] [%s]\n' "$1" "${10}" "$10"