Linux zip 命令:压缩文件或目录

我们经常会在 Windows 系统上使用 “.zip”格式压缩文件,其实“.zip”格式文件是 Windows 和 Linux 系统都通用的压缩文件类型,属于几种主流的压缩格式(zip、rar 等)之一,是一种相当简单的分别压缩每个文件的存储格式,本节要讲的 zip 命令,类似于 Windows 系统中的 winzip 压缩程序,其基本格式如下:

[root@localhost ~]#zip [选项] 压缩包名 源文件或源目录列表
注意,zip 压缩命令需要手工指定压缩之后的压缩包名,注意写清楚扩展名,以便解压缩时使用。

下面给大家举几个例子。

【例 1】zip 命令的基本使用。
复制代码
不仅如此,所有的压缩命令都可以同时压缩多个文件,例如:
复制代码
【例 2】使用 zip 命令压缩目录,需要使用“-r”选项,例如:

复制代码
版权声明: 本文为 InfoQ 作者【向阳逐梦】的原创文章。
原文链接:【http://xie.infoq.cn/article/e112bf1e06209a66cd081266d】。文章转载请联系作者。
评论