养浩然之气,活着不是为技术,请关心身边的人.
grep - .php .html .htm
上一篇 /
下一篇 2007-08-23 14:59:35
/ 个人分类:linux-Shell
#!/bin/sh
#this scrīpt must be run in the directory of your target
TARGET=$1
DIR=$2
if [ -d $DIR ];then
countphp=`ls $DIR | grep php | wc -l`
counthtm=`ls $DIR | grep htm | wc -l`
counthtml=`ls $DIR |grep html | wc -l`
if [ $countphp -ne 0 ];then
echo `pwd` >> /home/test/find.txt
grep -s $TARGET $DIR/*.php >> /home/test/find.txt
fi
if [ $counthtm -ne 0 ];then
echo `pwd` >> /home/test/find.txt
grep -s $TARGET $DIR/*.htm >> /home/test/find.txt
fi
if [ $counthtml -ne 0 ];then
echo `pwd` >> /home/test/find.txt
grep -s $TARGET $DIR/*.html >> /home/test/find.txt
fi
for i in `ls $DIR`
do
if [ -d $DIR/$i ]; then
cd $DIR/$i
temp=`pwd`
sh /home/test/shell.sh $TARGET $temp
fi
done
else
exit 1
fi
导入论坛
收藏
分享给好友
管理
举报
TAG:
linux-Shell