一、字符串比较
1. 字符串相等比较用“=”或“==”,但是有区别!!
在用echo输出变量内容时,要用双引号。
=~可以用于判断字符串的包含关系,参考:滑动验证页面
#目前只支持在64位机器编译
if [ "${ARCH}" == "" ]; then
ARCH=`getconf LONG_BIT`
echo "Compile in ${ARCH} bit"
fi
if [ "${ARCH}" == "32" ]; then
echo "do not support compile in 32 bit machine"
exit -1
fi
# 默认为Tlinux1.2
if [ "${MACHINE_ARCH_D}" == "" ]; then
MACHINE_ARCH_D=Tlinux1.2
tlinux_desc=`cat /etc/tlinux-release`
if [[ "${tlinux_desc}" =~ "1.2" ]]; then # 检测是否为Tlinux1.2
MACHINE_ARCH_D=Tlinux1.2
echo "MACHINE_ARCH_D:${MACHINE_ARCH_D}"
elif [[ "${tlinux_desc}" =~ "2.2" ]]; then # 检测是否为Tlinux2.2
MACHINE_ARCH_D=Tlinux2.2
echo "MACHINE_ARCH_D:${MACHINE_ARCH_D}"
else
echo "do not support compile in ${tlinux_desc}"
exit -1
fi
fi