[arch-general] Unzip archive in which are multiple sub zip archiers?
Christian Demsar
vixsomnis at fastmail.com
Fri Apr 17 20:19:44 UTC 2015
On Fri, Apr 17, 2015, at 01:12 PM, Csányi Pál wrote:
> 2015-04-17 18:53 GMT+02:00 Christian Demsar <vixsomnis at fastmail.com>:
> > On April 17, 2015 12:29:36 PM EDT, Maarten de Vries <maarten at de-vri.es> wrote:
> >>On 17 April 2015 at 18:08, Csányi Pál <csanyipal at gmail.com> wrote:
> >>> I just get a ZIP archive and want to unzip it.
> >>>
> >>> I'm using unzip to unpack this archive.
> >>>
> >>> But when I did first unzip command, I get more ZIP archives, which
> >>> have again in it more ZIP archives.
> >>>
> >>> Is there a command or application whic can unzip this ZIP archive and
> >>> it's sub ZIP archives at once?
> >>>
> >>That doesn't sound like a common enough use case that someone would
> >>have
> >>written a program just for that purpose. But you could write a simple
> >>shell
> >>script (or whatever you prefer) to recursively unzip a bunch of zip
> >>files.
> >>Keep in mind not to unzip the same files forever of course.
>
> > If you're not familiar with shell scripting I can write one (with detailed comments). I need the practice.
>
> OK, write one and I'm willing to try it out and modify if it would
> have GPL licence. :)
> I'm newbie in bash shell scripting.
>
> --
> Regards from Pal
http://pastebin.com/YJFvUt13
It works on my (single) test case so far. I don't have any more time to work in this right now, but I'll test edge cases and add more comments later (feedback is welcome).
If you use this, please, please, please back up your zip file in a different directory. I haven't tested it thoroughly enough to be confident that it won't suck your files into the black hole of /dev/null.
On a side note, it does check to make sure the directory doesn't exist, so it shouldn't clobber anything. That goes for the internal zips as well.
The only cryptic thing in the $IFS env var. That's needed for newline delimiters, so I can iterate over the zip files in a directory. I'll experiment with leaving that section out.
There's probably a bash guru out there that can do this with a one-liner, but that's beyond my skills (I'm a newbie at bash, too).
--
vixsomnis
More information about the arch-general
mailing list