Unzip subdirectory contents of zip file to /tmp?
11,664
The command would be to extract with folder names (default behavior):
unzip test.zip samples/* -d /tmp
without folder names (extracting files only contained in samples folder):
unzip -j test.zip samples/* -d /tmp
From man unzip
:
-j junk paths. The archive's directory structure is not recreated;
all files are deposited in the extraction directory (by default,
the current one).
Hope this helps!
Related videos on Youtube
Author by
andrew.46
The Tao is close, but you look far away. Life is simple yet you look for problems...
Updated on September 18, 2022Comments
-
andrew.46 over 1 year
As part of a scripted software installation on Xenial Xerus I have a zipped archive called 'test.zip' that contains, among other files, some files in a sub-directory called
samples
:andrew@athens:~/Desktop$ unzip -l test.zip Archive: test.zip Length Date Time Name --------- ---------- ----- ---- 0 2016-09-15 13:29 materials/ 66 2014-11-16 18:22 materials/preferences.kcfgc 21554 2014-11-16 18:22 materials/mainwindow.cpp 166 2016-09-15 13:29 materials/.zip 164 2014-11-16 18:22 materials/Messages.sh 0 2016-09-15 13:28 samples/ 35147 2014-11-16 18:22 samples/LICENCE 631 2014-11-16 18:22 samples/README.md 2344 2014-11-16 18:22 samples/main.cpp --------- ------- 60072 9 files andrew@athens:~/Desktop$
Using Xenial Xerus's commandline
unzip
utility how do I extract the contents only ofsamples
, decompressing them to/tmp
? -
Anwar over 7 yearswhat does
-j
do? -
Terrance over 7 years@Anwar Added from the manpage what -j does.
-
Anwar over 7 yearsOP wanted to extract the contents of samples, there might be some directory they don't want to lose.
-
Terrance over 7 years@Anwar With folder names would keep the directory structure.