A brief post just to try not to forget. If you want to search for a string in files with a specific name contained in zip archives, this might help you:

find . -name "201501*.zip" -exec unzip -c '{}' "**/600*" \; 2> /dev/null | grep "CONFIG;[0-9]+;" - | more

Sometimes the archives did not contained the file we are looking for, so in order to avoid messages like “caution: filename not matched:  **/600*” we are redirecting stderr to /dev/null. Obviously, after writing my own, I’ve discovered that somebody else already solved a similar problem with the command (actually the manpage says that it is a script) zipgrep. So, the previous line could be rewritten as

find . -name "201501*.zip" -exec zipgrep -s "CONFIG;[0-9]*" '{}' '*/600*' \;

In the end the first try is not that useless, since it could be easily adapted to other archive types.

Advertisements