脚本中的read命令用法操作
作者:互联网
脚本中的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
标签:脚本,yn,read,echo,NewsourceCOde,fi,line,用法,源码 来源: https://blog.csdn.net/kuangbende_cike/article/details/113915559