shell使用总结

一、字符串比较

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值