How to use grep in a .zip file

There are 3 files a.csv, b.csv, c.csv zipped as abh.zip, now you can run the grep command on abh.zip (is there any wild card with which only grep is executed for the c. Csv file inside zip file).

+6
source share
2 answers

If you have zipgrep (which, AFAIK, comes with zip utilities), you can simply do

 zipgrep "pattern" abh.zip c.csv 

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

Alternatively, if you do not have zipgrep , but you have unzip , you can do

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

which unpacks the file into a pipe ( -p ) and then sends it as grep ped.

+7
source

you can run the zipgrep command using the pip statement as shown below. Then you can only set the name "

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

0
source

Source: https://habr.com/ru/post/989264/


All Articles