ZIP archives produced on Mac OS X systems usually include a
__MACOSX directory which is useless, annoying, and unwanted on pretty much every other OS.
For unpacking ZIP archives I use Info-ZIP, which I think is the default unzipper on most Linux distributions. What's the best way of having Info-ZIP's
unzip always and automatically suppress the extraction of any
__MACOSX directory which may be present?
According to the
unzip man page, the
-x option can be used to exclude directories from processing, and indeed adding
-x __MACOSX/* to the end of my
unzip command line does the trick. But I don't want to have to type this all the time. The man page also says that command-line options can be read from the
UNZIP environment variable, but apparently this works only for those options which come before the archive name (whereas
-x must come after it):
$ export UNZIP="-x __MACOSX/*" $ unzip foo.zip unzip: cannot find or open __MACOSX, __MACOSX.zip or __MACOSX.ZIP.
Is there any better solution than wrapping
unzip in a shell script which automatically adds
-x __MACOSX/* to the end of the command line?