Linux zip命令压缩文件或目录解说
发布时间:2023-12-13 11:15:29 所属栏目:Linux 来源:DaWei
导读: 我们经常会在 Windows 系统上使用 “.zip”格式压缩文件,其实“.zip”格式文件是 Windows 和 Linux 系统都通用的压缩文件类型,属于几种主流的压缩格式(zip、rar等)
我们经常会在 Windows 系统上使用 “.zip”格式压缩文件,其实“.zip”格式文件是 Windows 和 Linux 系统都通用的压缩文件类型,属于几种主流的压缩格式(zip、rar等)之一,是一种相当简单的分别压缩每个文件的存储格式, 本节要讲的 zip 命令,类似于 Windows 系统中的 winzip 压缩程序,其基本格式如下: [root@localhost ~]#zip [选项] 压缩包名 源文件或源目录列表 注意,zip 压缩命令需要手工指定压缩之后的压缩包名,注意写清楚扩展名,以便解压缩时使用。 选项 含义 -r 递归压缩目录,及将制定目录下的所有文件以及子目录全部压缩。 -m 将文件压缩之后,删除原始文件,相当于把文件移到压缩文件中。 -v 显示详细的压缩过程信息。 -q 在压缩的时候不显示命令的执行过程。 -压缩级别 压缩级别是从 1~9 的数字,-1 代表压缩速度更快,-9 代表压缩效果更好。 -u 更新压缩文件,即往压缩文件中添加新文件。 下面给大家举几个例子。 【例 1】zip 命令的基本使用。 [root@localhost ~]# zip ana.zip anaconda-ks.cfg adding: anaconda-ks.cfg (deflated 37%) #压缩 [root@localhost ~]# ll ana.zip -rw-r--r-- 1 root root 935 6月 1716:00 ana.zip #压缩文件生成 不仅如此,所有的压缩命令都可以同时压缩多个文件,例如: [root@localhost ~]# zip test.zip install.log install.log.syslog adding: install.log (deflated 72%) adding: install.log.syslog (deflated 85%) #同时压缩多个文件到test.zip压缩包中 [root@localhost ~]#ll test.zip -rw-r--r-- 1 root root 8368 6月 1716:03 test.zip #压缩文件生成 【例 2】使用 zip 命令压缩目录,需要使用“-r”选项,例如: [root@localhost ~]# mkdir dir1 #建立测试目录 [root@localhost ~]# zip -r dir1.zip dir1 adding: dir1/(stored 0%) #压缩目录 [root@localhost ~]# ls -dl dir1.zip -rw-r--r-- 1 root root 160 6月 1716:22 dir1.zip #压缩文件生成。 (编辑:哈尔滨站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Linux系统调用表或汇编语言中的cheetsheet
- 通过命令行在Linux中查找进程数
- linux – 在Spark sbin /文件夹中的stop-all.sh没有停止所有
- linux – grubby致命错误:无法找到合适的模板
- linux – pthreads线程在堆栈中预先故障的最佳方法是什么?
- Linux文件上的退格问题
- LINUX学习:php简单统计在线人数的方法
- linux – SCSI读取(10)和写入(10)与SCSI通用接口
- Device eth0 does not seem to be present, delaying initi
- linux – 使用log4j将日志数据写入syslog
推荐文章
站长推荐