How to use grep in .zip file

2020-06-18 10:30发布

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).

标签: linux shell
2条回答
ゆ 、 Hurt°
2楼-- · 2020-06-18 10:39

you can run zipgrep command with pip operator as below.then you can only set name"

zipgrep "name" abh.zip | grep c.csv

查看更多
成全新的幸福
3楼-- · 2020-06-18 10:56

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

zipgrep "pattern" abh.zip c.csv

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

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

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

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

查看更多
登录 后发表回答