#!/bin/bash
if [ "$1" == "test1" ]
then
echo 1
elif [ "$1" == "test2" ]
then
echo 2
fi
sh-3.2$ ./sh0731.sh test1
1
sh-3.2$ ./sh0731.sh test2
2
sh-3.2$ ./sh0731.sh test3
3
sh-3.2$ cat sh0731.sh
test1=1
test2=2
test3=3
cmd='echo $'
cmd+=$1
eval $cmdsh-3.2$
shell script 如下
test1=1
test2=2
test3=3
cmd='echo $'
cmd+=$1
eval $cmd
這年頭還有人在用 sh
Google 都是 Bash,ksh...