[英]grep -f when the pattern file also has some empty lines
grep命令是否可以抑制模式文件中空行的影响? 我宁愿选择此选项,而不是总是检查和过滤新生的模式文件。
这是一个示例(在pattern_file
,有一个空行):
$ cat pattern_file
APPLE
PEAR
$ cat file
Nothing
fruit
$ grep -f pattern_file file
Nothing
fruit
要忽略病毒码文件中的空行:
grep -f <(grep . pattern_file) file
grep -v '^$'
实际上,这会抓住换行以外的所有行。 您可以像这样将结果通过管道传递到grep: grep -v '^$'| otherGrep
grep -v '^$'| otherGrep
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.