Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use grep command on zip files

Tags:

unix

I want to grep for today's date from zip file. How can do this?

I have a zip file called sen2616.z I want to get all the data for today's date 09.02.2014

like image 663
Martini_geek Avatar asked Sep 02 '14 13:09

Martini_geek


People also ask

How do I grep in a zip file?

Unfortunately, grep doesn't work on compressed files. To overcome this, people usually advise to first uncompress the file(s), and then grep your text, after that finally re-compress your file(s)… You don't need to uncompress them in the first place. You can use zgrep on compressed or gzipped files.

How do I grep multiple zip files?

If you want to grep all files, not only zipped files, then you could use ugrep, which allows to do that with -z flag.

How do I grep inside a gz file?

You need to use zgrep command which invokes grep on compressed or gzipped files. All options specified are passed directly to the grep command or egrep command.


2 Answers

Please use zipgrep.

zgrep is for gz files, not for zip files.

like image 144
Krzysztof Avatar answered Sep 20 '22 22:09

Krzysztof


In my case zgrep didn't work on a normal .zip file. I had to use zipgrep instead.

like image 38
Johann Avatar answered Sep 19 '22 22:09

Johann