Dec 25

linux下快速查找文件带到指定内容的文件 不指定

bkkkd , 17:14 , 开发应用 , 评论(0) , 引用(0) , 阅读(7678) , Via 本站原创 | |
在windows下我习惯于使用search and replace软件进行搜索文件中是否存在某个字符串.
现在在linux下也能这样操作了.将以下代码保存为searchcontent.sh
find $1 -iname "$2"|while read filename
do
    code=`cat $filename |grep $3 -nr`
    if [ "$code" != "" ];then
        echo $filename
        echo $code
    fi
done|more

设置searchcontent.sh为可执行
chmod +x ./searchcontent.sh

使用该脚本搜索文件
./s.sh /www/238000_net/ "*.php" "eval"

搜索/www/目录下的后缀为php的文件中是否存在eval字符串,如果存在输出文件名及代码的内容
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]