Shell(grep)

Posted by YaPi on June 4, 2022

grep

  • grep option pattern file1 fil2
  • command grep option pattern
option
  • -v 不显示匹配行信息
  • -i 搜索时忽略大小写
  • -n 显示行号
  • -r 递归搜索
  • -E 支持扩展正则表达式
  • -F 不按正则表达式匹配,按照字符串字面意思匹配
  • -c 只显示匹配总行数
  • -w 匹配整词
  • -x 匹配整行
  • -l 只显示文件名,不显示内容
  • -s 不显示错误信息

egrep

  • grep 默认不支持扩展正则表达式,只支持基础正则表达式
  • 使用grep -E可以支持扩展正则表达式
  • 使用egrep可以扩展正则表达式,与grep -E等价