0

Here is what I am doing: I want to find which zip files includes this number with number itself for example i want the result be like this :

7505857289 AIRCDR

where the number is my search result and AIRCDRis zipfilename that contains this number among 100000 files

1 Answers1

1

According to your comment the “haystack” of your search is a set of gzipped text files (based on the file name extension .gz). You can scan them with the zgrep command, a wrapper around the grep command that decompresses gzipped files on the fly and supports most of the same options as grep itself.

Thus you can simply run

zgrep -oHe 7505857289 <FILES>...

which will print the name of the source file followed by a colon and the matching character sequence for each match.

If you need a specific output format I recommend that you transform it. For matching text followed by a space and the source file name that would be:

zgrep ... | sed -re 's/^([^:]*):(.*)$/\2 \1/'
David Foerster
  • 36,890
  • 56
  • 97
  • 151