Mini HOWTO: Getting file names in Zip-archives using Bash

I'm gathering stats about my archives, and one of these is getting all the file names in them. There are some challenges about it, so let me show the required commands.

Getting file names from the one archive:

unzip -l /path/to/zip-file | tail -n +4 | head -n -2 | cut -c31-

Executing pipelined commands in xargs:

xargs -I {} -i sh -c 'command1 | command2 | ... | commandN'

For my case I've used the expression:

find . -iname "*.zip" -print0 | xargs -0 -n1 -I {} -i sh -c 'unzip -l {} | tail -n +4 | head -n -2 | cut -c31-' | sort | uniq -c

Yeah, yeah, black magic, gotcha Smiley Good luck!


Popular posts from this blog

DIY: Business cards in LaTeX

Python vs JS vs PHP for embedded systems

Web application framework comparison by memory consumption