#!/bin/bash
# method 0: for i in $#
# method 1
args=$#
for (( i=1; i<=$args; i++ ))
do
echo "$i - ${!i}"
done
# method 2
for arg
do
case "$arg" in
-*=*) value=`echo "$arg" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;;
esac
echo "${arg} is $value"
case "$arg" in
--help=*) echo "help: $value";;
*)
;;
esac
done
备份地址: 【迭代bash脚本参数】