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:
Executing pipelined commands in xargs:
xargs -I {} -i sh -c 'command1 | command2 | ... | commandN'
For my case I've used the expression:
Yeah, yeah, black magic, gotcha Good luck!
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 Good luck!
Comments
Post a Comment