How to handle more than 10 parameters in shell

Use curly braces to set them off:

echo "${10}"

Any positional parameter can be saved in a variable to document its use and make later statements more readable:

city_name=${10}

If fewer parameters are passed then the value at the later positions will be unset.

You can also iterate over the positional parameters like this:

for arg

or

for arg in "$@"

or

while (( $# > 0 ))    # or [ $# -gt 0 ]
do
    echo "$1"
    shift
done

Leave a Comment