【點滴】LINUX之zip/unzip命令__LINUX

來源:互聯網
上載者:User
一、zip命令 用法: zip [參數] <打包後的檔案名稱> <需要打包的檔案/檔案夾> 參數: -a     #將檔案轉為ASCII模式 -F     #嘗試修複損壞的壓縮檔 -h --help     #顯示協助介面 -m     #壓縮後刪除源檔案 -q     #安靜模式,在壓縮時不顯示具體的指令執行過程 -r     #遞迴,將指定目錄下所有檔案和子目錄一起壓縮處理 -S     #包含系統和隱藏檔案 -t     #把壓縮檔的最後修改日期設定為指定日期,格式為mmddyyyy -P     #帶密碼加密 -e     #安全模式加密
執行個體:> lsimage-1.jpg image-2.jpg image-3.jpg image-4.jpg image-5.png image-6.png#壓縮指定檔案到t.zip> zip t.zip image-1.jpg image-2.jpgadding: image-1.jpg (stored 0%)adding: image-2.jpg (stored 0%)#壓縮file目錄> zip -r aa.zip file/#查看壓縮檔裡的詳細檔案> zipinfo aa.zipArchive: aa.zipZip file size: 1120 bytes, number of entries: 7drwxr-xr-x 3.0 unx 0 bx stor 15-May-27 10:40 file/-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-4.jpg-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-3.jpg-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-1.jpg-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-6.png-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-5.png-rw-r--r-- 3.0 unx 0 bx stor 15-May-26 10:17 file/image-2.jpg7 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%#帶密碼壓縮> zip -P 123456 -r b.zip file/#安全模式加密> zip -e -r b.zip file/Enter password:Verify password:



二、unzip命令 用法: unzip [參數] <壓縮檔> [解壓的檔案/路徑] 參數: -d     #指定解壓路徑 -t     #檢查檔案是否正確
執行個體:#解壓到a目錄> unzip b.zip -d a/Archive: b.zipcreating: a/file/extracting: a/file/image-4.jpgextracting: a/file/image-3.jpgextracting: a/file/image-1.jpgextracting: a/file/image-6.pngextracting: a/file/image-5.pngextracting: a/file/image-2.jpg> lltotal 20drwxr-xr-x 3 users users 4096 May 28 09:58 a-rw-r--r-- 1 users users 1120 May 28 09:31 b.zipdrwxr-xr-x 2 users users 4096 May 27 10:40 file> cd a/ > ll total 4 drwxr-xr-x 2 users users 4096 May 27 10:40 file#解壓到aa目錄,aa不存在,會自動建立> unzip b.zip -d aa#解壓其中一個檔案到aa目錄,image-1.jpg路徑要求完整(file/image-1.jpg)> unzip b.zip file/image-1.jpg -d aa> unzip aa.zipArchive: aa.zipcreating: file/extracting: file/image-4.jpgextracting: file/image-3.jpgextracting: file/image-1.jpgextracting: file/image-6.pngextracting: file/image-5.pngextracting: file/image-2.jpg> lltotal 8-rw-r--r-- 1 users users 1120 May 28 09:23 aa.zipdrwxr-xr-x 2 users users 4096 May 27 10:40 file> cd file/> lltotal 0-rw-r--r-- 1 users users 0 May 26 10:17 image-1.jpg-rw-r--r-- 1 users users 0 May 26 10:17 image-2.jpg-rw-r--r-- 1 users users 0 May 26 10:17 image-3.jpg-rw-r--r-- 1 users users 0 May 26 10:17 image-4.jpg-rw-r--r-- 1 users users 0 May 26 10:17 image-5.png-rw-r--r-- 1 users users 0 May 26 10:17 image-6.png


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.