两个shell脚本的实例
拷贝文件脚本
- 将一个文件从一个文件夹指定的拷贝到另外一个文件夹
#!/bin/bash
broad_file="/home/user/Zeekr/sa8295p-hqx-4-2-4-0_hlos_dev_la/lagvm/LINUX/android/out/target/product/zeekr_dhu/vendor/bin/hw/[email protected]"
dirana3_file="/home/user/Zeekr/sa8295p-hqx-4-2-4-0_hlos_dev_la/lagvm/LINUX/android/out/target/product/zeekr_dhu/vendor/lib64/hw/vendor.aptiv.hardware.dirana3.so"
diagnostic_file="/home/user/Zeekr/sa8295p-hqx-4-2-4-0_hlos_dev_la/lagvm/LINUX/android/out/target/product/zeekr_dhu/system/priv-app/DiagnosticService/DiagnosticService.apk"
dest_folder="/home/user/shared"
ERROR_START='\e[101m'
PROMPT_START='\e[44m'
GREEN_COL='\e[32m'
SUCCESS_START='\e[104m'
NON_COL='\e[0m'
copy_file_index=1
function cpFile(){
if [[ ! -e $dest_folder ]];then
echo -e "$ERROR_START$dest_folder is not exit, and return$NON_COL"
exit
fi
if [[ ! -f $1 ]];then
echo "$source_file is not exist and exit"
exit
else
cp $1 $dest_folder
if [[ $? -eq 0 ]];then
echo -e "$SUCCESS_START cp $1 to $dest_folder successfully$NON_COL"
else
echo -e "$ERROR_START cp $1 to $dest_folder failed$NON_COL"
fi
fi
}
if [[ -z "$1" ]];then
echo -e "$PROMPT_START The following file you can copy:\n1-broadcastradio2.0\n2-Dirana3.so\n3-diagnosticService$NON_COL"
read -p "which do you want to copy:" copy_file_index
else
copy_file_index=$1
fi
case $copy_file_index in
1)
echo -e "$GREEN_COL Start to copy broadcastRadio2.0$NON_COL"
cpFile $broad_file;;
2)
echo "Start to copy Dirana3.so"
cpFile $dirana3_file;;
3)
echo "Start to copy DiagnosticServer"
cpFile $diagnostic_file;;
*)
echo "The number you input is not supported, so break";;
esac
编译文件
- 到指定文件执行脚本,然后转到另外一个脚本下直接编译命令
#!/bin/bash
script_folder="/home/user/Zeekr/sa8295p-hqx-4-2-4-0_hlos_dev_la/lagvm/LINUX/android"
compile_folder="/home/user/Zeekr/sa8295p-hqx-4-2-4-0_hlos_dev_la/lagvm/LINUX/android/vendor/aptiv/hal/radio"
echo -e "\e[42m [cd $script_folder] \e[0m"
cd $script_folder
echo -e "\e[42m [source file] \e[0m"
source build/envsetup.sh && lunch 82
echo -e "\e[42m [cd $compile_folder] \e[0m"
cd $compile_folder
echo -e "\e[42m [compile radio] \e[0m "
mma
if [ $? -eq 0 ];then
echo -e "\e[42m [compile success ]\e[0m"
else
echo -e "\e[33m [compile failure]\e[0m"
fi
标签:脚本,shell,echo,实例,file,folder,copy,COL,0m
From: https://www.cnblogs.com/wanghao-boke/p/17515039.html