假设脚本为test.sh文件
#!/bin/bash
#base_url="http://localhost:8080"
echo $0
if [[ ${1} = "test" ]]
then
base_url="http://localhost:8080/"
else
base_url="http://10.25.102.151:8080/"
fi
sh test.sh test
说明:
${0} 为shell脚本本身的名称,如上操作:
echo ${0} 为:test.sh
echo ${1} 为:test
if条件中,两边必须有空格,否则就会报错,[[test: command not found