grep 查询包含内容的文件

加入到 ~/.bashrc 或者 ~/.bash_profile

bash

 1 export GREPF_FILES=/mnt/d/Developer:/mnt/e/Developer
 2 
 3 function grepf() {
 4     if [ $# -ne 1 ]; then
 5         cat <<EOF
 6 Usage:
 7     grepf PATTERN
 8 
 9 Variable:
10     GREPF_FILES    grep file
11 
12 Example:
13     grepf \"hello\"
14     GREPF_FILES=. grepf \"hello\"
15 EOF
16         return
17     fi
18     grep -irn $1 $(echo $GREPF_FILES|tr ':' ' ')
19 }

 

 

mingw

 1 #export GREPF_FILES="$(cygpath 'D:\Developer') $(cygpath 'E:\Developer')"
 2 
 3 function grepf() {
 4     if [ $# -ne 1 ]; then
 5         cat <<EOF
 6 Usage:
 7     grepf PATTERN
 8 
 9 Variable:
10     GREPF_FILES    grep file
11 
12 Example:
13     grepf \"hello\"
14     GREPF_FILES=. grepf \"hello\"
15 EOF
16         return
17     fi
18     grep -irn $1 $GREPF_FILES
19 }

 

命令

$ grepf
Usage:
    grepf PATTERN

Variable:
    GREPF_FILES    grep file

Example:
    grepf \"2005\"
    GREPF_FILES=. grepf \"2005\"

 

posted @ 2018-04-28 17:01  Bob-wei  阅读(812)  评论(0编辑  收藏  举报