替换工程shell
来源:互联网 发布:自定义整理相册软件 编辑:程序博客网 时间:2024/04/30 18:49
项目使用新的规范,需要将之前的工程重新修改,写一shell脚本,输入老工程名,新工程名来替换里面需要替换的部分
#!/bin/bashif [ $# -ne 2 ] ;then echo "please enter an old project name and a new project name!"else old_name=$1 new_name=$2 len=$(expr length "${new_name}") let "len = len - 3" pro_name=$(echo ${new_name}|cut -c1-$len) workflow_name=$(echo ${new_name}|cut -c1-$len)"-wf" echo "DEBUG: old name is: "${old_name}", new name is: "${new_name}", workflow name is: "${workflow_name} echo "DEBUG: rename project name..." mv ${old_name} ${new_name} cd ${new_name} echo "DEBUG: rename properties" mv ${old_name}.properties ${new_name}.properties sed -i "s:bd-wh/bd-wh-common:bd-wh-common-cd:g" ${new_name}.properties sed -i "s:bd-wh/${old_name}:${new_name}:g" ${new_name}.properties echo "DEBUG: replace runjob.sh" sed -i "s:bd-wh/bd-wh-common:bd-wh-common-cd:g" runJob.sh sed -i "s:bd-wh/${old_name}:${new_name}:g" runJob.sh sed -i "s:${old_name}.properties:${new_name}.properties:g" runJob.sh echo "DEBUG: replace coordinator.xml" sed -i "s:${old_name}-cd:${new_name}:g" coordinator.xml sed -i "s:${old_name}.dataset:${new_name}-dataset:g" coordinator.xml datasets_begin=$(grep -n "<datasets>" coordinator.xml | cut -d ":" -f 1) datasets_end=$(grep -n "</datasets>" coordinator.xml | cut -d ":" -f 1) let "dataset_begin = datasets_begin + 1" let "dataset_end = datasets_end - 1" echo "DEBUG: delete dataset dataset_begin: "${dataset_begin}", dataset_end: "${dataset_end} sed -i ${dataset_begin},${dataset_end}d coordinator.xml common_dataset='\ \ \ \ <include>${hdfs_address_prefix}/bd-wh-common-cd/datasets.xml</include>' sed -i "${datasets_begin}a${common_dataset}" coordinator.xml echo "DEBUG: replace workflow.xml" sed -i "s:${old_name}-wf:${workflow_name}:g" workflow*.xml sed -i "s:${old_name}:${pro_name}:g" workflow*.xml echo "DEBUG: replace putShell.sh" sed -i "s:bd-wh/::g" putShell.sh reRunJob=reRunJob.sh if [ -f "${reRunJob}" ]; then echo "DEBUG: replace reRunJob.sh" sed -i "s:bd-wh/${old_name}/${old_name}:${new_name}/${new_name}:g" ${reRunJob} fi echo "DEBUG: dos2unix ..." dos2unix *.* echo "DEBUG: checking ..." grep -ER "bd-wh|bd-wh-common|${old_name}" . echo "DEBUG: checked." #sed -i "s:bd-wh/${old_name}:${new_name}:g" `grep 'bd-wh.${old_name}' -rl ${cpath}`fi
0 0
- 替换工程shell
- Shell替换
- Shell替换
- Shell替换
- shell替换
- Shell 学习8 - Shell 替换
- SHELL 文本替换
- SHELL的字符替换
- Bash Shell命令行替换
- shell 文本替换命令
- shell 变量替换
- shell 替换文件内容
- shell变量替换
- shell中替换
- shell中的命令替换
- shell 批量查找替换
- Linux Shell参数替换
- shell参数替换之##%%
- POJ_3096_Surprising Strings
- OS X 下 文件夹合并方法
- java如何对Map结构按照key值排序
- linux下用cron定时执行任务的方法
- js实现页面定时跳转
- 替换工程shell
- Android软件开发之获取通讯录联系人信息 + android联系人信息的存储结构 + Android联系人读取操作笔记
- 抽象数据类型(链表)
- asp.net中cookies的使用
- code::blocks(版本10.05) 配置opencv2.4.3
- Linux中环境变量文件及配置
- SYSZUXpinyin中文输入法的移植(到QT)
- 【Ajax】代理直接输出JSON或者XML的解决方法
- ArcGIS教程:太阳辐射分析的应用示例