#!/bin/bash
ROOT_DIR='/root/temp/wow'
KEYWORD='ad_union'
KEYWORD2='advertisement'
#for i in $(find $ROOT_DIR -name "*.*" -exec grep "$KEYWORD" {} \;)
for i in $(find $ROOT_DIR -name "*.*")
do
ifile=$(grep "$KEYWORD" $i)
if [ "$?" -eq "0" ]
then
FILE_NUMBER=$(echo $ifile | awk -F"\"" '{print $2}' | awk -F"/" '{print $NF}' | awk -F"." '{print $1}' | awk -F"_" '{print $NF}')
#sed -i "s#ad\_union\_[0-9][0-9]#union\_$FILE_NUMBER#g" $i
sed -i "s#ad\_union\_$FILE_NUMBER#union\_$FILE_NUMBER#g" $i
fi
ifile=$(grep "$KEYWORD2" $i)
if [ "$?" -eq "0" ]
then
FILE_NUMBER2=$(echo $ifile | awk -F"\"" '{print $2}' | awk -F"/" '{print $NF}' | awk -F"." '{print $1}' | awk -F"_" '{print $NF}')
sed -i "s#advertisement\/$FILE_NUMBER2\/ad\_$FILE_NUMBER2#upload\/$FILE_NUMBER2\/$FILE_NUMBER2#g" $i
fi
done
阅读(553) | 评论(0) | 转发(0) |