- [root@localhost ~]# ls
- 1.txt 2.txt anaconda-ks.cfg d6z
- [root@localhost ~]# du -sh 1.txt
- 1.6M 1.txt
- [root@localhost ~]# zip 1.txt.zip 1.txt 将 1.txt 压缩
- adding: 1.txt (deflated 83%)
- [root@localhost ~]# du -sh 1.txt.zip 压缩后文件大小
- 272K 1.txt.zip
- [root@localhost ~]# ls 压缩完成后原来的文件不会被删除
- 1.txt 1.txt.zip 2.txt anaconda-ks.cfg d6z
- [root@localhost ~]# zip -r d6z.zip 2.txt d6z 压缩目录要加 - r
- adding: 2.txt (stored 0%)
- adding: d6z/ (stored 0%)
- adding: d6z/33.txt (stored 0%)
- adding: d6z/22.txt.xz (deflated 1%)
- adding: d6z/222.txt (deflated 71%)
- adding: d6z/111.txt (deflated 79%)
- adding: d6z/11.txt (deflated 79%)
- adding: d6z/hyc/ (stored 0%)
- adding: d6z/hyc/.bashlogout (stored 0%)
- adding: d6z/hyc/.bashprofile (deflated 21%)
- adding: d6z/hyc/.bashrc (deflated 23%)
- adding: d6z/hyc/1.txt (deflated 73%)
- adding: d6z/hyc/2.txt (deflated 73%)
- adding: d6z/hyc/2/ (stored 0%)
- adding: d6z/hyc/2/11.txt (deflated 79%)
- [root@localhost ~]# du -sh d6z.zip
- 4.0K d6z.zip
- [root@localhost ~]# unzip d6z.zip 解压压缩包
- Archive: d6z.zip
- replace 2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
- extracting: 2.txt
- creating: d6z/
- extracting: d6z/33.txt
- inflating: d6z/22.txt.xz
- inflating: d6z/222.txt
- inflating: d6z/111.txt
- inflating: d6z/11.txt
- creating: d6z/hyc/
- extracting: d6z/hyc/.bashlogout
- inflating: d6z/hyc/.bashprofile
- inflating: d6z/hyc/.bashrc
- inflating: d6z/hyc/1.txt
- inflating: d6z/hyc/2.txt
- creating: d6z/hyc/2/
- inflating: d6z/hyc/2/11.txt
- [root@localhost ~]# unzip 1.txt.zip -d ./test 指定解压路径
- Archive: 1.txt.zip
- inflating: ./test/1.txt
- [root@localhost ~]# unzip 1.txt.zip -d ./test/aa.txt 无法指定解压后的文件名, 文件名固定
- Archive: 1.txt.zip
- inflating: ./test/aa.txt/1.txt
来源: http://www.bubuko.com/infodetail-2515003.html