#!/bin/bash if [ $# -ne 1 ];then echo "lack of filename" exit 1 fi while read line do NUM=`find .|grep vm$|grep -v 'auto-config.xml'|xargs grep "$line"|wc -l` if [ $NUM -gt 0 ];then CHANGE_WORD=`echo $line|tr "." "_"` echo 'has changed value is :' $CHANGE_WORD find .|grep vm$|grep -v 'auto-config.xml'|xargs sed -i "s/$line/$CHANGE_WORD/g" echo 'the find command result ' $? if [ $? -eq 0 ];then echo 'change value check' CHANGE_NUM=`find .|grep vm$|grep -v 'auto-config.xml'|xargs grep $CHANGE_WORD |wc -l` echo "$line has changed . num is " $CHANGE_NUM if [ $CHANGE_NUM -gt 0 ];then echo 'change value success' else echo 'change value false' fi fi fi done < $1
0 条评论。