脚本中的read命令用法操作

该脚本主要用于从指定路径提取源码,并进行文件拷贝、目录结构调整及Git推送操作。在执行过程中,脚本会检查当前目录是否存在NewsourceCOde,如果存在则提示用户是否覆盖,接着将源码拷贝到NewsourceCOde目录下,然后移动目录结构并删除原始源码目录,最后将调整后的NewsourceCOde重命名为纯源码并推送到Git仓库。
摘要由CSDN通过智能技术生成

脚本中的read命令用法操作
检出一倍push到git仓库

function dosomething ()
{
	if [ -d NewsourceCOde ]
	then
		echo "当前目录下已经有NewsourceCOde,此操作可能导致原有文件被覆盖,是否覆盖,是请按y/Y"
		read yn
		if [ $yn != "Y" ] && [ $yn != "y" ] 
		then
			echo "你已选择中途退出"
			exit
		fi
		rm -rf NewsourceCOde
	fi
	mkdir NewsourceCOde
	
	line=0
	for f in `find 纯源码/ -name "src"`
	do
		sourceDir[$line]="${f#*/}"
		echo "拷贝 $1/${sourceDir[$line]} 到 NewsourceCOde/ 并保留目录层次"
		cp  -a --parent $1/${sourceDir[$line]} NewsourceCOde/
		((line++))
	done


	for f in `find 纯源码/ -name "lib"`
	do
		libfile="${f#*/}"
		echo "拷贝 $1/$libfile 到 NewsourceCOde/ 并保留目录层次"
		cp  -a --parent $1/$libfile NewsourceCOde/
	done
	
	mv NewsourceCOde/$1/* NewsourceCOde/
	dirstr=$1
	if [ ${dirstr:0:1} == "/" ]
	then
		dirstr=${dirstr#*/}
	fi
	rm -rf NewsourceCOde/${dirstr%%/*}
	rm -rf 纯源码
	mv NewsourceCOde 纯源码
}



if [ $# != 1 ]
then
	echo "请在命令后面附带要提取源码的路径"
	echo "例如: ./getPushCode /d/ccsv7code/combineCode-S1-20190111"
	exit
fi



if [ ! -d $1 ]
then
	echo "路径不存在,请检查斜杠是否用反了"
	echo "正确示范: ./getPushCode /d/ccsv7code/combineCode-S1-20190111"
	exit
fi

echo "你确定从 $1 提取.c .h文件吗? Y/N [Y]"
read yn
if [ $yn == "Y" ] || [ $yn == "y" ] 
then
	dosomething $1
else
	echo "你没有选择目录, 请在询问时输入Y或y"
	exit
fi
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值