[root@hf-01 d6z]# mkdir -p /tmp/hf/han/hanfeng
[root@hf-01 d6z]# cd /tmp/hf
[root@hf-01 hf]# touch 1.txt
[root@hf-01 hf]# touch /tmp/hf/han/wu.txt
[root@hf-01 hf]# touch /tmp/hf/han/hanfeng/66.txt
[root@hf-01 hf]# cd /tmp/d6z
[root@hf-01 d6z]# ls /tmp
12.txt 1.txt 2.txt.bz2 d6z ha.txt.xz hf mysql.sock vim.txt
[root@hf-01 d6z]# cp -r /tmp/hf .
[root@hf-01 d6z]# ls
1.txt 4.txt 5.txt 8.xt hf
[root@hf-01 d6z]# tree hf/
hf/
├── 1.txt
└── han
├── hanfeng
│ └── 66.txt
└── wu.txt
2 directories, 3 files
[root@hf-01 d6z]# cp 1.txt hf/han/hanfeng/
[root@hf-01 d6z]# du -sh hf/
1.5M hf/
[root@hf-01 d6z]# zip 1.txt.zip 1.txt
adding: 1.txt (deflated 74%)
[root@hf-01 d6z]# du -sh 1.txt.zip
388K 1.txt.zip
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt hf
[root@hf-01 d6z]# zip -r hafe.zip 8.txt hf
zip warning: name not matched: 8.txt
adding: hf/ (stored 0%)
adding: hf/han/ (stored 0%)
adding: hf/han/hanfeng/ (stored 0%)
adding: hf/han/hanfeng/66.txt (stored 0%)
adding: hf/han/hanfeng/1.txt (deflated 74%)
adding: hf/han/wu.txt (stored 0%)
adding: hf/1.txt (stored 0%)
[root@hf-01 d6z]# ls
1.txt 8.txt hf hafe.zip
zip压缩文件后不删除之前的文件
[root@localhost d6z]# unzip yasuo.zip
Archive: yasuo.zip
replace 2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: 2.txt
extracting: hf/han/hanfeng/66.txt
inflating: hf/han/hanfeng/1.txt
extracting: hf/han/wu.txt
extracting: hf/1.txt
extracting: hf/11.txt
[root@localhost d6z]#
[root@localhost d6z]# mkdir lala
[root@localhost d6z]# unzip 1.txt.zip -d lala/
Archive: 1.txt.zip
inflating: /lala/1.txt
[root@localhost d6z]# unzip -l yasuo.zip
Archive: yasuo.zip
Length Date Time Name
--------- ---------- ----- ----
1283485 11-09-2017 16:02 2.txt
0 11-10-2017 10:40 hf/
0 11-10-2017 10:41 hf/han/
0 11-10-2017 10:45 hf/han/hanfeng/
0 11-10-2017 10:41 hf/han/hanfeng/66.txt
1283485 11-10-2017 10:45 hf/han/hanfeng/1.txt
0 11-10-2017 10:41 hf/han/wu.txt
0 11-10-2017 10:40 hf/1.txt
0 11-10-2017 10:40 hf/11.txt
--------- -------
2566970 9 files
[root@localhost d6z]#
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt hafe.zip hf
[root@hf-01 d6z]# tar -cvf hf.tar hf/
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
[root@hf-01 d6z]#
[root@hf-01 d6z]# tar -cf hf.tar hf/
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt hafe.zip hf hf.tar
[root@hf-01 d6z]#
[root@hf-01 d6z]# tar -xvf hf.tar
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt hafe.zip hf hf.tar
[root@hf-01 d6z]# tar -cvf han.tar hf/ 1.txt 4.txt
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt hafe.zip han.tar hf hf.tar
[root@hf-01 d6z]# tar -tf han.tar
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# tar -cvf han.tar --exclude hanfeng hf/ 1.txt 4.txt
hf/
hf/han/
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# tar -cvf han.tar --exclude hanfeng --exclude wu.txt --exclude "*.txt" hf/ 1.txt 4.txt
hf/
hf/han/
[root@hf-01 d6z]# tar -czvf gurui.tar.gz hf/ 1.txt 4.txt
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# ls
1.txt 1.txt.zip 4.txt 5.txt 8.xt gurui.tar.gz hafe.zip han.tar hf hf.tar
[root@hf-01 d6z]# du -sh gurui.tar.gz 查看打包文件的大小
1.2M gurui.tar.gz
[root@hf-01 d6z]# du -sh hf/ 1.txt 4.txt
1.5M hf/
1.5M 1.txt
1.5M 4.txt
[root@hf-01 d6z]# tar -zxvf gurui.tar.gz
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# ls
1.txt 4.txt 8.xt gurui.tar.gz hafe.zip hf
1.txt.zip 5.txt gurui.tar.bz2 gurui.tar.xz han.tar hf.tar
[root@hf-01 d6z]# tar -cjvf gurui.tar.bz2 hf/ 1.txt 4.txt
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# ls
1.txt 4.txt 8.xt gurui.tar.gz han.tar hf.tar
1.txt.zip 5.txt gurui.tar.bz2 hafe.zip hf
[root@hf-01 d6z]# du -sh gurui.tar.bz2
432K gurui.tar.bz2
[root@hf-01 d6z]# tar -xjvf gurui.tar.bz2
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# tar -cJvf gurui.tar.xz hf/ 1.txt 4.txt
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# du -sh gurui.tar.xz
60K gurui.tar.xz
[root@hf-01 d6z]# tar -xJvf gurui.tar.xz
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt
[root@hf-01 d6z]# tar -tf gurui.tar.gz
hf/
hf/han/
hf/han/hanfeng/
hf/han/hanfeng/66.txt
hf/han/hanfeng/1.txt
hf/han/wu.txt
hf/1.txt
1.txt
4.txt