[英]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.