shell 实现修改项目版本号

 #!/bin/bash
stty erase '^H'
function checkVerisonFormat()
{	
	CustomerSWVersion=$1
	inputVersion=$2
	curVer=`echo ${CustomerSWVersion:0:${#CustomerSWVersion}-3}`
	len=${#inputVersion}
	if [ $len -gt 7 ];then
		echo "input length is ok" >console
	else
		echo  "Input length to short,please input again !" 
		count=1
		return $count
	fi
	input=`echo ${inputVersion:0:${#inputVersion}-3}`
	if [ $curVer == $input ];then
		count=0
		return $count
	else
		echo  "Input the version is wrong!please check "
		count=1
		return $count
	fi

}

#loop main
echo -e "\033[32m Change Version Step \033[0m"
CustomerSWVersion=`cat deviceParaStatic.conf | grep CustomerSWVersion | awk -F '=' '{print$2}'`
InnerSWVersion=`cat deviceParaStatic.conf | grep InnerSWVersion | awk -F '=' '{print$2}'`

flag=0
while true
do
	if [ $flag == 0 ];then
		echo -e "The CustomerSWVersion is \033[31m $CustomerSWVersion \033[0m"
		echo "you want to change CustomerSWVersion to:(enter space to skip)"
		read name
		if [ $name ];then
			a=$(checkVerisonFormat $CustomerSWVersion $name)
			if [ $? -eq 0 ];then
				sed -i "s|$CustomerSWVersion|$name|g" "deviceParaStatic.conf"
				sed -i "s|$CustomerSWVersion|$name|g" "devInf.conf" 
				echo "$name" > ./.././.././.././../app_bsp/version/fwver.conf
				#app_bsp/version/fwver.conf
				echo -e "\033[32m you change CustomerSWVersion to $name success! \033[0m"
				echo -e "\033[32m deviceParaStatic.conf \033[0m"
				echo -e "\033[32m devInf.conf \033[0m"
				echo -e "\033[32m fwver.conf \033[0m"
				flag=1
			fi
		else
			echo -e "\033[31m The input is a space ,skip the setting! \033[0m"
			flag=1
		fi
		echo -e "\033[31m $a \033[0m"
	fi

	
	if [ $flag == 1 ];then
		echo -e "the InnerSWVersion is \033[31m $InnerSWVersion \033[0m"
		echo "you want to change InnerSWVersion to:(enter space to skip)"
		read name
		if [ $name ];then
			a=$(checkVerisonFormat $InnerSWVersion $name)
			if [ $? -eq 0 ];then
				sed -i "s|$InnerSWVersion|$name|g" "deviceParaStatic.conf"
				echo -e "\033[32m you change InnerSWVersion to $name success \033[0m"
				echo -e "\033[32m deviceParaStatic.conf \033[0m"
				flag=2
			fi
		else
			echo -e "\033[31m The input is a space ,skip the setting! \033[0m"
			flag=2
		fi
		echo -e "\033[31m $a \033[0m"
	fi
	
	if [ $flag == 2 ];then
		break
	fi
	
done



  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘多拉的面

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值