9

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 of samples, decompressing them to /tmp?

andrew.46
  • 39,359

1 Answers1

15

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!

Terrance
  • 43,712