Bash - 从不包含特定模式的文件中获取行

时间:2016-04-12 14:55:07

标签: regex linux bash grep

我想从文件中提取所有不符合特定模式的行。

pattern="tmp/[...]/include/linux/*.h"
file contains:
17937;/home/[...]/tmp/[...]/include/linux/header.h;484;16;[Other text here]
37417;/home/[...]/tmp/[...]/src/file.cpp;1851;41;[Other text here]
17945;/home/[...]/tmp/[...]/include/linux/*/header.h;484;16;[Other text here]

预期结果只是第二行。

我已经尝试了下面这行,我得到了文件的全部内容:

grep -E -v $pattern file

它仅适用于波纹管线,但还不够:

grep -E -v .h file

如何获得所需的输出?

0 个答案:

没有答案