养浩然之气,活着不是为技术,请关心身边的人.

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

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

数据统计

  • 访问量: 21553
  • 日志数: 146
  • 建立时间: 2007-08-01
  • 更新时间: 2008-02-20

RSS订阅

Open Toolbar