
作為 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$
使用 Xenial Xerus 的命令unzip
列實用程式如何擷取僅內容的samples
,將它們解壓到/tmp
?
答案1
該命令是使用資料夾名稱進行提取(預設行為):
unzip test.zip samples/* -d /tmp
沒有資料夾名稱(僅提取樣本資料夾中包含的檔案):
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).
希望這可以幫助!