我的Ubuntu Server脚本工具【3】

方便查询文件中的字符串

文件名:findstr

View Code
 1 if [ $# -ne 2 ]

 2 then

 3         echo "info : invalid argument number [$#]"

 4         echo "usage: $0 string file_filter"

 5         exit -1

 6 fi

 7 

 8 find . -name "$2" -print|while read ff

 9 do

10         nn=`grep "$1" $ff|wc -l`

11         if [ $nn -gt 0 ]

12         then

13                 echo "==================== $ff ================="

14                 grep "$1" $ff

15                 echo "=========================================="

16         fi

17 done

 

你可能感兴趣的:(ubuntu server)