Linux unzip命令 – 解壓縮zip格式文件
unzip命令用于解壓縮zip格式文件,雖然Linux系統中更多的使用tar命令進行對壓縮包的管理工作,但有時也會收到同Windows系統常用的.zip和.rar格式的壓縮包文件,unzip格式便派上了用場。直接使用unzip命令解壓縮文件后,壓縮包內原有的文件會被提取并輸出保存到當前工作目錄下。
語法格式:unzip [參數] 壓縮包
常用參數:
-l 顯示壓縮文件內所包含的文件
-v 執行時顯示詳細的信息
-c 將解壓縮的結果顯示到屏幕上,并對字符做適當的轉換
-n 解壓縮時不要覆蓋原有的文件
-j 不處理壓縮文件中原有的目錄路徑
參考實例
將壓縮包文件解壓到當前工作目錄中:
[root@linuxcool ~]# unzip latest.zip
Archive: latest.zip
creating: wordpress/
inflating: wordpress/xmlrpc.php
inflating: wordpress/wp-blog-header.php
inflating: wordpress/readme.html
inflating: wordpress/wp-signup.php
inflating: wordpress/index.php
………………省略部分輸出信息………………
將壓縮包文件解壓到指定的目錄中:
[root@linuxcool ~]# unzip latest.zip -d /home
Archive: latest.zip
creating: /home/wordpress/
inflating: /home/wordpress/xmlrpc.php
inflating: /home/wordpress/wp-blog-header.php
inflating: /home/wordpress/readme.html
inflating: /home/wordpress/wp-signup.php
inflating: /home/wordpress/index.php
………………省略部分輸出信息………………
測試壓縮包文件是否完整,文件有無損壞:
[root@linuxcool ~]# unzip -t latest.zip
Archive: latest.zip
testing: wordpress/ OK
testing: wordpress/xmlrpc.php OK
testing: wordpress/wp-blog-header.php OK
testing: wordpress/readme.html OK
testing: wordpress/wp-signup.php OK
testing: wordpress/index.php OK
………………省略部分輸出信息………………