1 2 3 等...
从命令行或函数传递给脚本的位置参数:
#!/bin/bash
# $n is the n'th positional parameter
echo "$1"
echo "$2"
echo "$3"
以上的输出是:
~> $ ./testscript.sh firstarg secondarg thirdarg
firstarg
secondarg
thirdarg
如果位置参数的数量大于 9,则必须使用花括号。
# "set -- " sets positional parameters
set -- 1 2 3 4 5 6 7 8 nine ten eleven twelve
# the following line will output 10 not 1 as the value of $1 the digit 1
# will be concatenated with the following 0
echo $10 # outputs 1
echo ${10} # outputs ten
# to show this clearly:
set -- arg{1..12}
echo $10
echo ${10}