Linux压缩命令
zip命令类似于Windows系统中的winzip压缩程序
基本语法
zip [选项] 压缩包名 源文件或源目录列表
选项说明
1 -r:递归压缩目录,及将指定目录下的所有文件以及子目录全部压缩。
2 -m:将文件压缩之后,删除原始文件,相当于把文件移到压缩文件中。
3 -v:显示详细的压缩过程信息。
4 -q:在压缩的时候不显示命令的执行过程。
5 -压缩级别:压缩级别是从1~9的数字,-1代表压缩速度更快,-9代表压缩效果更好。
6 -u:更新压缩文件,即往压缩文件中添加新文件。
使用举例:
[root@localhost home]# ls
hello hello-hard hello-soft test test-soft
[root@localhost home]# zip hello.zip hello hello-hard
adding: hello (deflated 99%)
adding: hello-hard (deflated 99%)
[root@localhost home]# ls
hello hello-hard hello-soft hello.zip test test-soft
[root@localhost home]# zip test.zip test test-soft
adding: test/ (stored 0%)
adding: test-soft/ (stored 0%)
[root@localhost home]# ls
hello hello-hard hello-soft hello.zip test test-soft test.zip
[root@localhost home]#
unzip命令可以查看和解压缩zip文件
基本语法
unzip [选项] 压缩包名
选项说明
1 -d 目录名:将压缩文件解压到指定目录下。
2 -n:解压时并不覆盖已经存在的文件。
3 -o:解压时覆盖已经存在的文件,并且无需用户确认。
4 -v:查看压缩文件的详细信息,包括压缩文件中包含的文件大小、文件名以及压缩比等,但并不做解压操作。
5 -t:测试压缩文件有无损坏,但并不解压。
6 -x 文件列表:解压文件,但不包含文件列表中指定的文件。
使用举例
[root@localhost home]# ls
hello.zip test.zip
[root@localhost home]# unzip -v hello.zip
Archive: hello.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
10240 Defl:N 99 99% 07-11-2019 01:28 dda39bf9 hello
10240 Defl:N 99 99% 07-11-2019 01:28 dda39bf9 hello-hard
-------- ------- --- -------
20480 198 99% 2 files
[root@localhost home]# unzip hello.zip
Archive: hello.zip
inflating: hello
inflating: hello-hard
[root@localhost home]# ls
hello hello-hard hello.zip test.zip
[root@localhost home]# unzip -d zip test.zip
Archive: test.zip
creating: zip/test/
creating: zip/test-soft/
[root@localhost home]# ls
hello hello-hard hello.zip test.zip zip
[root@localhost home]# ls zip
test test-soft
[root@localhost home]#
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步