如何在.zip文件中使用grep [英] How to use grep in .zip file

查看:95
本文介绍了如何在.zip文件中使用grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有3个压缩为abh.zip的文件a.csv,b.csv,c.csv,现在可以在abh.zip上执行grep命令(是否有任何通配符,只有grep才能运行c.压缩文件中的csv文件.)

There are 3 files a.csv,b.csv,c.csv zipped as abh.zip, now is it possible to execute grep command on abh.zip (is there any wild card by which only grep run for c.csv file inside zip).

推荐答案

如果您有 zipgrep (AFAIK随 zip 实用程序一起提供),则您可以简单地做

If you have zipgrep (which, AFAIK, is shipped with the zip utilities), then you can simply do

zipgrep "pattern" abh.zip c.csv

zipgrep 支持大多数与香草 grep 相同的基本选项.

zipgrep supports most of the same basic options as vanilla grep.

或者,如果您没有 zipgrep ,但是具有 unzip ,则可以

Alternatively, if you don't have zipgrep but you have unzip, you can do

unzip -p abh.zip c.csv | grep "pattern"

它将文件解压缩到管道( -p ),然后将其发送为 grep ped.

which unzips the file to a pipe (-p) then sends it to be grepped.

这篇关于如何在.zip文件中使用grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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