Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有多个.gz文件要在其中搜索关键字。我可以通过管道zcat结果来做到这grep一点:
.gz
zcat
grep
zcat some.file.* | grep "keyword_1" | ... | grep "keyword_n"
此命令的输出虽然只是匹配的行,但不会包含文件名。有什么办法可以将文件名附加到zcat输出?
尝试zgrep代替zcat:
zgrep
zgrep -H keyword some.file.*
如果你想用来egrep获得模式匹配:
egrep
export GREP=egrep zgrep -H -e "(keyword1|keyword2)" some.file.*