2019-07-02 22:03:08 +08:00
|
|
|
# Linux 系统下压缩和解压 Zip 文件
|
|
|
|
|
|
|
|
## 安装
|
|
|
|
|
|
|
|
安装指令如下:
|
|
|
|
|
2021-11-13 16:14:07 +08:00
|
|
|
```bash
|
|
|
|
sudo apt-get install zip unzip
|
|
|
|
sudo pacman -S zip unzip
|
|
|
|
```
|
2019-07-02 22:03:08 +08:00
|
|
|
|
|
|
|
## 压缩
|
|
|
|
|
|
|
|
使用 zip 对多个文件或文件夹进行压缩如下:
|
|
|
|
|
2021-11-13 16:14:07 +08:00
|
|
|
```bash
|
|
|
|
zip <zip package> <file1> <file2> ...
|
|
|
|
# 递归
|
|
|
|
zip -r <zip package> <file1> <file2> ...
|
|
|
|
```
|
2019-07-02 22:03:08 +08:00
|
|
|
|
|
|
|
## 解压
|
|
|
|
|
|
|
|
使用 unzip 将压缩包解压到指定目录下:
|
|
|
|
|
2021-11-13 16:14:07 +08:00
|
|
|
```bash
|
|
|
|
unzip <zip package> -d <output path>
|
|
|
|
```
|
|
|
|
|
|
|
|
## 查看压缩包内容
|
|
|
|
|
|
|
|
```bash
|
|
|
|
zip -sf <zip package>
|
|
|
|
```
|
|
|
|
|
|
|
|
## 删除压缩包中的内容
|
|
|
|
|
|
|
|
```bash
|
|
|
|
zip -dv <zip package> <file to be deleted>
|
|
|
|
```
|