[arch-general] Re: Unzip archive in which are multiple sub zip archiers?

Maarten de Vries maarten at de-vri.es
Fri Apr 17 20:34:47 UTC 2015



On 04/17/2015 10:19 PM, Christian Demsar wrote:
> 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).

You should be able to avoid fiddling with IFS by using:

    shopt -s nullglob
    zipfiles=(*.zip)

It also has the advantage of not spawning a process to find zip files. 
The nullglob option is needed in case there are no zip files, otherwise 
(*.zip) will turn into a literal ('*.zip') instead of an empty array.

Regards,
Maarten


More information about the arch-general mailing list