userName=${1} aaa() { echo select test from psql where user=${userName} and id=1; } bbb() { echo select test from psql where user=${userName} and id=2; } ccc() { echo select test from psql where user=${userName} and id=3; } $1 [root@stark shell]# ./test.sh aaa select test from psql where user=aaa and id=1 [root@stark shell]# ./test.sh bbb select test from psql where user=bbb and id=2 [root@stark shell]# ./test.sh ccc select test from psql where user=ccc and id=3
userName=${1} aaa=1 bbb=2 ccc=3 echo select test from psql where user=${userName} and id=$(evalecho'$'"$1"); [root@stark shell]# ./test.sh aaa select test from psql where user=aaa and id=1 [root@stark shell]# ./test.sh bbb select test from psql where user=bbb and id=2 [root@stark shell]# ./test.sh ccc select test from psql where user=ccc and id=3