使用grep时如何保留文件头?

发布于 2025-01-16 11:52:42 字数 285 浏览 0 评论 0原文

我有两个文件。一个非常大的文件,带有标题和大约数百万行 (chrall.txt.gz)。

另一个文件 (extract0.3.txt) 具有单列/值列表,用于交叉引用较大的文件。如果值匹配(它们都应该),则会创建一个新文件并输出匹配的行。我正在使用下面的 grep 命令:

gunzip -c chrall.txt.gz | grep -Fwf extract0.3.txt > output

但是,这不会打印我的标题行。我将如何保留 chrall.txt.gz 的标题行

I have two files. One very large file with a header and approx several million rows (chrall.txt.gz).

Another file (extract0.3.txt) with a single column/list of values to cross-reference the larger file. If the value match (they all should) a new file is created outputting the matched lines. I am using the grep command below:

gunzip -c chrall.txt.gz | grep -Fwf extract0.3.txt > output

However, this does not print my header line. How would I retain the header line of chrall.txt.gz

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文