#!/bin/sh
printf 'number of parameters: %d\n' $#
printf 'all parameters:\n'
printf '\t%s\n' "$@"
printf 'looping\n'
for p; do
printf '\t%s\n' "$p"
done
It produces the following output with different parameters:
zsh-4.3.12[t]% ./params one two
number of parameters: 2
all parameters:
one
two
looping
one
two
zsh-4.3.12[t]% ./params three four five
number of parameters: 3
all parameters:
three
four
five
looping
three
four
five
If for <varname>; do ... doesn't work
with your shell, be more explicit:
for <varname> in "$@"; do ...
Some shells provide the getopts builtin for more advanced parameter parsing.