如何在压缩文本文件中搜索文本模式? [英] How can I grep for a text pattern in a zipped text file?

查看:19
本文介绍了如何在压缩文本文件中搜索文本模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的每日供稿文件大小平均为 2 GB.这些文件会在每个月底归档到一个 zip 文件中,并存储在网络共享中.有时,我需要在这些文件中搜索某些记录.为此,我通过远程桌面连接到共享服务器,将文件解压缩到临时文件夹,运行 grep(或 PowerShell)搜索,然后删除临时文件夹.现在,由于我们的服务器磁盘空间不足,不再建议将它们全部解压缩到临时文件夹中.在对磁盘或网络资源影响最小的情况下,对这些压缩文件进行正则表达式搜索的有效方法是什么?

Our daily feed file averages 2 GB in size. These files get archived to a single zip file at the end of each month and stored in a network share. From time to time, I have a need to search for certain records in those files. I do this by connecting by remote desktop to the shared server, unzip the files to a temp folder, run grep (or PowerShell) search, and then delete the temp folder. Now, because our server is running low in disk space, it is no longer recommeded to unzip them all to a temp folder. What is an efficient way to do a regex search on those zipped files with minimum impact on disk or network resources?

推荐答案

zgrep 在 Linux 上.如果您使用的是 Windows,则可以下载 GnuWin,其中包含 zgrep 的 Windows 端口.

zgrep on Linux. If you're on Windows, you can download GnuWin which contains a Windows port of zgrep.

这篇关于如何在压缩文本文件中搜索文本模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆