简单的压缩、解压缩
# 压缩文件
zip test.zip test.log
# 压缩文件夹
zip -r test.zip test
# 解压缩
unzip test.zip
使用实例
zip unzip 安装
# CentOS 安装
sudo yum install -y zip unzip
# Ubuntu & Debian 安装
sudo apt install -y zip unzip
zip 压缩文件
压缩单个文件
将 test.log 文件压缩为 test.zip
zip test.zip test.log
压缩多个文件
压缩多个文件到 test.zip 中,多个文件用空格隔开
zip test.zip test.log a.log b.log
指定被压缩文件路径
指定被压缩文件 test.log 路径, -j 保存文件名称及其内容,而不存放任何目录名称
如不加 -j 参数,在压缩时,会把 test.log 的指定路径都压缩到文件中
zip -j test.zip /var/log/test.log
指定压缩文件保存目录
将压缩文件 test.zip 保存到指定目录 home 中,亦可指定被压缩文件 test.log 路径