用注释注释grep的“包含”文件?

use*_*618 5 shell grep

我做了一个grep包含某些字符串的排序。也就是说,给我文件中包含某些字符串的行。如

grep -fv include file  > out
Run Code Online (Sandbox Code Playgroud)

该命令查找file并发送到out与文件中的内容相匹配的每一行include。没有问题。工作正常。

如何在我的include文件中添加评论?

例如,我想用一些(例如#)注释来注释该文件,以解释我所包含的内容。所以我想grep忽略include文件中以#. 我怎么做?

vin*_*c17 1

对于具有进程替换(如 bash 和 zsh)的 shell:

grep -f <(grep -v '^#' include) file > out
Run Code Online (Sandbox Code Playgroud)