Linux unzip, excluding everything in the folder and under it

Hi, I need to unzip a file that a directory may have, and I want to exclude everything from this directory, I tried many options and looked here, but did not seem to find a good solution.

This is the contents of the zip file: Note that the depth of the EXCLUDE folder is unknown, but we must exclude all

$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 extracts only the files inside 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.

+6
source share
2 answers

You need to specify an exclude pattern so that it is passed to unzip . Otherwise, the shell will be expanded by the shell before passing it to unzip .

Try:

 unzip patch2.zip -x "EXCLUDE/*" 
+8
source
Answer to

@dogbane is correct.

But I'm still adding one more option [hopefully] because you're on Linux:

 mc 

(aka: Midnight Commander)

Run it, and then: in the right pane, go to where you want your files to end, and in the left pane, go "inside" the ZIP file, and at this first level, select + copy what you (i.e. select all and deselect the EXCLUDE folder, for example)

mc VERY flexible and pleasant to use, especially for tar / untar / zip / move / delete / rename files ... (on windows the equivalent of TotalCommander and I often use its “synchronization”) synchronize backups and origin). This allows you to navigate through archives as if they were uncompressed (an attempt to minimize the actual decompression only to the “navigation” part, so that you do not uncompress them twice).

0
source

Source: https://habr.com/ru/post/956965/


All Articles