在文件夹中的gzip压缩文件中找到字符串 [英] find string inside a gzipped file in a folder
本文介绍了在文件夹中的gzip压缩文件中找到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有更简单的方法来确定文件夹中的gzip压缩文件是否具有特定的模式? p>
zcat ABC / myzippedfile1.txt.gz | greppattern match
zcat ABC / myzippedfile2.txt.gz | grep模式匹配
我可以在单行中执行相同的操作,而不是编写脚本,对于所有文件夹和子文件夹?
for f in`ls * .gz`;做echo $ f; zcat $ f | grep< pattern> ;;完成;
解决方案
zgrep将查看gzip压缩文件,具有-R递归选项和-H显示文件名选项:
zgrep -R --include = *。gz -H模式匹配。
My current problem is that I have around 10 folders, which contain gzipped files (around on an average 5 each). This makes it 50 files to open and look at.
Is there a simpler method to find out if a gzipped file inside a folder has a particular pattern or not?
zcat ABC/myzippedfile1.txt.gz | grep "pattern match"
zcat ABC/myzippedfile2.txt.gz | grep "pattern match"
Instead of writing a script, can I do the same in a single line, for all the folders and sub folders?
for f in `ls *.gz`; do echo $f; zcat $f | grep <pattern>; done;
解决方案
zgrep will look in gzipped files, has a -R recursive option, and a -H show me the filename option:
zgrep -R --include=*.gz -H "pattern match" .
这篇关于在文件夹中的gzip压缩文件中找到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文