Hi I have to unzip a file that could have a Directory and I want to exclude everything within that directory, I tried lot of options and looked here as well, but doesn't seem to find any good solution.
These are the contents of the zip file: Please note the depth of EXCLUDE folder is unknown, but we have to exclude everything
$unzip -l patch2.zip
Archive: patch2.zip
Length Date Time Name
--------- ---------- ----- ----
0 2013-10-29 17:42 EXCLUDE/
0 2013-10-29 17:24 EXCLUDE/inner/
0 2013-10-29 17:24 EXCLUDE/inner/inner1.txt
0 2013-10-29 15:45 EXCLUDE/file.txt
0 2013-10-29 15:44 patch.jar
0 2013-10-29 15:44 system.properties
--------- -------
0 6 files
I tried this command, which only extract the files within it, but not the folder and its contents:
$unzip -l patch2.zip -x EXCLUDE/*
Archive: patch2.zip
Length Date Time Name
--------- ---------- ----- ----
0 2013-10-29 17:42 EXCLUDE/
0 2013-10-29 17:24 EXCLUDE/inner/
0 2013-10-29 17:24 EXCLUDE/inner/inner1.txt
0 2013-10-29 15:44 patch.jar
0 2013-10-29 15:44 system.properties
--------- -------
0 5 files
Thanks for the help.
You need to quote the exclude pattern so that it is passed to unzip
. Otherwise it will be expanded by the shell before being passed to unzip
.
Try:
unzip patch2.zip -x "EXCLUDE/*"