directory=${1-`pwd`} #如果没有设置参数,则默认置为当前目录 for a #没有指明列表,则默认使用$@ for planet in "Mercury 36" "Venus 67" "Earth 93" "Mars 142" "Jupiter 483" do set -- $planet # 解析$planet到$@,比如"Mercury 36"就分成"Mercury", "36" echo "$1 $2,000,000 miles from the sun" done for a in {1..10} # 从1到10的序列 do echo -n "$a " done #命令行参数处理,case while [ $# -gt 0 ]; do # Until you run out of parameters . . . case "$1" in -d|--debug) # "-d" or "--debug" parameter? DEBUG=1 ;; -c|--conf) CONFFILE="$2" shift if [ ! -f $CONFFILE ]; then echo "Error: Supplied file doesn't exist!" exit $E_CONFFILE # File not found error. fi ;; esac shift # Check next set of parameters. done
2009年7月29日星期三
Advanced Bash Scripting Guide 7-10
订阅:
博文评论 (Atom)
没有评论:
发表评论