Linux怎么解压zip压缩文件电脑如何解压zip文件
如需學(xué)習(xí)視頻,請(qǐng)查看本頭條號(hào)簡(jiǎn)介,免費(fèi)在線觀看學(xué)習(xí)視頻
1. 前言
通常情況下,Linux系統(tǒng)并不會(huì)產(chǎn)生zip文件,而是由用戶把zip文件上傳到Linux系統(tǒng)中,產(chǎn)生解壓的需求。
2. 安裝zip解壓工具unzip
以CentOS7.5最小化安裝為例,系統(tǒng)并沒(méi)有集成unzip工具,需要額外安裝
[root@zcwyou ~]# yum -y install unzip
看到以下輸出即代表安裝成功。
Running transaction
Installing : unzip-6.0-19.el7.x86_64 1/1
Verifying : unzip-6.0-19.el7.x86_64 1/1
Installed:
unzip.x86_64 0:6.0-19.el7
Complete!
linux安裝unzip
3. 解壓文件
先查看一下壓縮文件
[root@zcwyou zip]# ll *.zip
查詢結(jié)果如下
total 4
-rw-r--r--. 1 root root 3032 Dec 4 17:14 zcwyou.zip
解壓這個(gè)zcwyou.zip文件
[root@zcwyou zip]# unzip zcwyou.zip
執(zhí)行過(guò)程如下:
Archive: test.zip
inflating: 333.txt
extracting: abc.txt
inflating: cisco1.txt
inflating: cisco2.txt
extracting: compress.txt
extracting: cp1.txt
extracting: cp2.txt
inflating: cut2.txt
extracting: cut.txt
extracting: diff1.txt
extracting: diff2.txt
creating: dir123/
extracting: hard123.txt
extracting: hard.txt
extracting: linux123.txt
extracting: soft.txt
extracting: test.txt
linux使用unzip解壓zip文件
可以看到,unzip程序創(chuàng)建了一個(gè)目錄dir123/,并且解壓了一些文件。目錄dir123是壓縮文件里的一個(gè)目錄。
檢查:
[root@zcwyou zip]# ll
total 40
-rw-r--r--. 1 root root 315 Nov 27 16:15 333.txt
-rw-r--r--. 1 root root 9 Nov 21 11:39 abc.txt
-rw-r--r--. 1 root root 173 Oct 13 15:24 cisco1.txt
-rw-r--r--. 1 root root 179 Oct 13 15:24 cisco2.txt
-rw-r--r--. 1 root root 0 Oct 12 14:40 compress.txt
-rw-r--r--. 1 root root 0 Oct 11 10:23 cp1.txt
-rw-r--r--. 1 root root 0 Oct 11 10:23 cp2.txt
-rw-r--r--. 1 root root 57 Oct 12 13:45 cut2.txt
-rw-r--r--. 1 root root 50 Oct 12 11:59 cut.txt
-rw-r--r--. 1 root root 9 Oct 13 14:59 diff1.txt
-rw-r--r--. 1 root root 18 Oct 13 15:00 diff2.txt
drwxr-xr-x. 2 root root 6 Dec 4 17:06 dir123
-rw-r--r--. 1 root root 0 Nov 26 17:47 hard123.txt
-rw-r--r--. 1 root root 0 Nov 26 17:47 hard.txt
-rw-r--r--. 1 root root 0 Nov 29 17:25 linux123.txt
-rw-r--r--. 1 root root 0 Nov 26 17:47 soft.txt
-rw-r--r--. 1 root root 10 Nov 19 13:33 test.txt
-rw-r--r--. 1 root root 3032 Dec 4 17:14 zcwyou.zip
發(fā)現(xiàn)zcwyou.zip里的文件已經(jīng)被全部解壓出來(lái)了,并且保留了源文件zcwyou.zip。
解壓其它例子
檢查linux解壓的文件
4. 其它實(shí)用案例
4.1 把zcwyou.zip解壓到目錄/tmp
[root@zcwyou zip]# unzip -d /tmp zcwyou.zip
4.2 解壓不覆蓋原有文件
[root@zcwyou zip]# unzip -n zcwyou.zip
4.3 解壓到指定目錄不覆蓋原有文件
[root@zcwyou zip]# unzip -n -d /tmp zcwyou.zip
4.4 解壓到指定目錄并覆蓋原有文件
[root@zcwyou zip]# unzip -o zcwyou.zip -d /tmp/
4.5 列出壓縮包內(nèi)容
[root@zcwyou zip]# unzip -l zcwyou.zip
4.6 查看壓縮包信息,包括每個(gè)文件的壓縮率和總壓縮率。
[root@zcwyou zip]# unzip -v zcwyou.zip
Archive: test.zip
Length Method Size Cmpr Date Time CRC-32 Name
315 Defl:N 163 48% 11-27-2018 16:15 c785bec5 333.txt
9 Stored 9 0% 11-21-2018 11:39 b202eb3a abc.txt
173 Defl:X 120 31% 10-13-2018 15:24 ddc8760a cisco1.txt
179 Defl:X 121 32% 10-13-2018 15:24 c83f3111 cisco2.txt
0 Stored 0 0% 10-12-2018 14:40 00000000 compress.txt
0 Stored 0 0% 10-11-2018 10:23 00000000 cp1.txt
0 Stored 0 0% 10-11-2018 10:23 00000000 cp2.txt
57 Defl:X 40 30% 10-12-2018 13:45 cfaa04a8 cut2.txt
50 Stored 50 0% 10-12-2018 11:59 8bdf8936 cut.txt
9 Stored 9 0% 10-13-2018 14:59 d0864923 diff1.txt
18 Stored 18 0% 10-13-2018 15:00 12be2d98 diff2.txt
0 Stored 0 0% 12-04-2018 17:06 00000000 dir123/
0 Stored 0 0% 11-26-2018 17:47 00000000 hard123.txt
0 Stored 0 0% 11-26-2018 17:47 00000000 hard.txt
0 Stored 0 0% 11-29-2018 17:25 00000000 linux123.txt
0 Stored 0 0% 11-26-2018 17:47 00000000 soft.txt
10 Stored 10 0% 11-19-2018 13:33 769b1926 test.txt
820 540 34% 17 files
linux unzip查看壓縮包信息
4.7 測(cè)試壓縮文件
[root@zcwyou zip]# unzip -t zcwyou.zip
檢驗(yàn)結(jié)果如下:
Archive: test.zip
testing: 333.txt OK
testing: abc.txt OK
testing: cisco1.txt OK
testing: cisco2.txt OK
testing: compress.txt OK
testing: cp1.txt OK
testing: cp2.txt OK
testing: cut2.txt OK
testing: cut.txt OK
testing: diff1.txt OK
testing: diff2.txt OK
testing: dir123/ OK
testing: hard123.txt OK
testing: hard.txt OK
testing: linux123.txt OK
testing: soft.txt OK
testing: test.txt OK
No errors detected in compressed data of test.zip.
linux使用unzip測(cè)試壓縮包
5. unzip命令的其他選項(xiàng)
[root@zcwyou zip]# unzip -h
-p 解壓文件到重定向到pipe,但不顯示信息
-l 列出壓縮包里所有的文件
-f 更新壓縮包內(nèi)已有的文件,但不添加新文件
-t 測(cè)試壓縮包
-u 更新壓縮包內(nèi)已有的文件,并添加新文件
-z 僅顯示壓縮包文件的備注信息
-v 打印詳細(xì)的執(zhí)行過(guò)程。
-T 解壓時(shí)更新文件時(shí)間至解壓時(shí)間
-x 指定解壓哪些文件
-d 解壓時(shí)創(chuàng)建新的目錄
修改參數(shù):
-n 不覆蓋文件
-q 靜默模式
-o 靜默替換
-a 自動(dòng)轉(zhuǎn)換文本文件
-j 不處理壓縮文件中原有的目錄
-aa 把所有文件當(dāng)做文本文件
-U use escapes for all non-ASCII Unicode
-UU 忽略任何的Unicode字段
-C 壓縮文件時(shí)區(qū)分大小寫
-L 把壓縮文件里的文件名全部變?yōu)樾《?/p>
-X 存儲(chǔ)UID/GID信息
-V 保留VMS版本號(hào)
-K 保留setuid/setgid/tacky權(quán)限
-M 把輸出結(jié)果交由more打印
-O 指定字符編碼為 DOS,Windows 和 OS/2
-I 指定字符編碼為 UNIX編碼
總結(jié):zip文件一般由Windows系統(tǒng)壓縮,并上傳到Linux系統(tǒng)上,Linux系統(tǒng)使用unzip解壓縮,如果發(fā)生亂碼,需要使用選項(xiàng)-O指定字符編碼,比如GBK,GB18030.
點(diǎn)擊了解更多,快速查看更多的技術(shù)文章列表。
總結(jié)
以上是生活随笔為你收集整理的Linux怎么解压zip压缩文件电脑如何解压zip文件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 黑白棋怎么玩(学下象棋入门视频教程)
- 下一篇: 手机维修中如何用对地阻值法测量手机故障手