【发布时间】:2016-05-06 15:39:07
【问题描述】:
当我使用 grep (GNU grep) 2.22 打印时 not 以 # 开头或 not 为空,我需要这样做
$ grep -v '^#' fileNameIGrepFor | grep -v '^$'
我觉得这很难看,有没有更聪明的方法(请使用grep)
【问题讨论】:
-
只需使用 grep 的 "\|"运算符匹配
^#或^$: grep -v "^#\|^$" 文件名
标签: regex unix grep regex-negation