
В рамках скриптовой установки программного обеспечения на Xenial Xerus у меня есть сжатый архив под названием «test.zip», содержащий, среди прочих файлов, некоторые файлы в подкаталоге с именем 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$
unzip
Как извлечь файл с помощью командной строки Xenial Xerus?только содержимоеиз samples
, распаковав их в /tmp
?
решение1
Команда будет извлекать с именами папок (поведение по умолчанию):
unzip test.zip samples/* -d /tmp
без имен папок (извлечение только файлов, содержащихся в папке samples):
unzip -j test.zip samples/* -d /tmp
От 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).
Надеюсь это поможет!