find string in file (need to be improved)

来源:互联网 发布:now直播软件下载 编辑:程序博客网 时间:2024/06/06 16:25

maybe it will be useful when we want to find a variable in a directory.

target=$1traversal(){    cd "$1"    for x in *    do       if [ -f $x ]      then        #echo $x        grep $target $x>null        if [ $? = 0 ]        then          echo $PWD/$x        fi      fi      if [ -d $x ]      then        traversal "$PWD/$x"      fi    done}traversal $PWD

use like this

./a.sh call

原创粉丝点击