三剑客之grep基础使用

2016-10-10  本文已影响31人  uangianlap
grep

grep egrep fgrep的区别

grep: Global search REgular expression and Pring out the line.
    -E : 实现使用扩展正则表达式进行匹配
    -F : 使用固定字符串进行匹配
            -e: 后接匹配模式列表(pat-list)
egrep:
    -G : 实现使用基本正则表达式
fgrep: 不支持正则表达式,性能更好.

grep使用概述:

    grep [OPTIONS] PATTERN [FILE...]
    grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]
    OPTIONS:
        --color=auto: CentOS7中已默认设置
    -i,--ignore-case: 匹配时忽略字母大小写
    -v, --invert-match: 反转匹配,即显示不匹配的行
    -o, --only-matching: 只匹配搜索的内容部分
        -e pat-list: 后接匹配模式,可以跟多个
    -E, --extended-regexp: 使用扩展的正则表达式
    -q, --quiet, --silent: 静默匹配,即不会输出到屏幕(often in bash shell script)
    -A NUM, --after-context=NUM: 同时打印在匹配到的每一行后NUM行内容
    -B NUM, --before-context=NUM
    -C NUM, -context=NUM: 相当于 A+B.
上一篇下一篇

猜你喜欢

热点阅读