zip/unzip 用来压缩和解压缩文件。
- 压缩 a.log b.log
$touch {a..e}.log
$ls
a.log b.log c.log d.log e.log
$zip test.zip a.log b.log
adding: a.log (stored 0%)
adding: b.log (stored 0%)
$ls
a.log b.log c.log d.log e.log test.zip
- 在test.zip里追加 c.log d.log
$zip test.zip c.log d.log
adding: c.log (stored 0%)
adding: d.log (stored 0%)
- 查看test.zip里的文件
$unzip -l test.zip
Archive: test.zip
Length Date Time Name
--------- ---------- ----- ----
0 08-26-2021 23:02 a.log
0 08-26-2021 23:02 b.log
0 08-26-2021 23:02 c.log
0 08-26-2021 23:02 d.log
--------- -------
0 4 files
- 从test.zip里删除a.log
$unzip -d test.zip a.log
deleting: a.log
- 压缩 a.log b.log c.log d.log e.log成 my.zip并删除原始文件
$zip -m my.zip a.log b.log c.log d.log e.log
adding: a.log (stored 0%)
adding: b.log (stored 0%)
adding: c.log (stored 0%)
adding: d.log (stored 0%)
adding: e.log (stored 0%)