zoukankan      html  css  js  c++  java
  • Simple But Useful Samples About 'grep' Command(简单实用的grep 命令)

    Do the following:

    grep -rnw '/path/to/somewhere/' -e "pattern"
    • -r or -R is recursive,
    • -n is line number, and
    • -w stands match the whole word.
    • -l (lower-case L) can be added to just give the file name of matching files.
    • Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
    grep --include=*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"

    This will only search through the files which have .c or .h extensions. Similarly a sample use of --exclude:

    grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"

    Above will exclude searching all the files ending with .o extension. Just like exclude file it's possible to exclude/include directories through --exclude-dir and --include-dir parameter; for example, the following shows how to integrate --exclude-dir:

    grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

    This works very well for me, to achieve almost the same purpose like yours.

    For more options :

    man grep
  • 相关阅读:
    Android改app名称
    DNSLog注入笔记
    mac burp suite https证书安装
    python-requests-proxies判断学习
    mac java jdk 安装删除
    php简单一句话分析
    mysql盲注学习-1
    Python实现访问者模式
    Python operator模块和functools模块
    SQL 日期函数转换
  • 原文地址:https://www.cnblogs.com/garfieldcgf/p/5833451.html
Copyright © 2011-2022 走看看