#!/bin/bash
E_BADARGS=65
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` argument1 argument2 etc."
exit $E_BADARGS
fi
echo
index=1
for arg in "$*"
do
echo "Arg #$index = $arg"
let "index+=1"
done
echo "Entire arg list as single word."
echo
index=1
for arg in "$@"
do
echo "Arg #$index = $arg"
let "index+=1"
done
echo "Entire arg list as seperated words."
echo
index=1
for arg in $*
do
echo "Arg #$index = $arg"
let "index+=1"
done
echo "Entire arg list as seperated words."
echo
index=1
for arg in $@
do
echo "Arg #$index = $arg"
let "index+=1"
done
echo "Entire arg list as seperated words."
exit 0
从这个例子可以看出来$*和$@的差别,$*被引号括起来和不被引号括起来是有区别的,而$@被引号括起来和不被引号括起来是没有区别的。
阅读(837) | 评论(0) | 转发(0) |