【tar】
-z 同时使用gzip压缩
-j 同时使用bzip2压缩
-x 解包或解压缩
-t 查看tar包的文件
-c 建立一个tar包或压缩文件
-v 可视化
-f 文件名(多个参数时,将f放置在最后面)
压缩时-f文件名表示压缩后的文件名为filename
解压时-f文件名表示解压filename
--exclude filename 在打包或压缩时,不要将filename文件包含在内。
#打tar包 -cvf ls -l test_1112 total 120 -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:05 hero1.png -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:06 hero2.png -rw-rw-r--. 1 webuser webuser 38879 Oct 8 14:13 hero.png tar -cvf test_1112.tar test_1112 test_1112/ test_1112/hero1.png test_1112/hero.png test_1112/hero2.png ls -l total 124 drwxrwxrw-. 2 webuser webuser 4096 Nov 13 00:12 test_1112 -rw-rw-rw-. 1 webuser webuser 122880 Nov 13 00:19 test_1112.tar
# 查看文件的内容 -tf tar -tf test_1112.tar test_1112/ test_1112/hero1.png test_1112/hero.png test_1112/hero2.png
#解压 -xvf ls test_1112.tar tar -xvf test_1112.tar test_1112/ test_1112/hero1.png test_1112/hero.png test_1112/hero2.png ls -l test_1112 total 120 -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:05 hero1.png -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:06 hero2.png -rw-rw-r--. 1 webuser webuser 38879 Oct 8 14:13 hero.png
#压缩且使用gzip压缩 -zcvf tar -zcvf test_1112.tar.gz test_1112 test_1112/ test_1112/hero1.png test_1112/hero.png test_1112/hero2.png ls -l total 240 drwxrwxrw-. 2 webuser webuser 4096 Nov 13 00:12 test_1112 -rw-rw-rw-. 1 webuser webuser 122880 Nov 13 00:24 test_1112.tar -rw-rw-rw-. 1 webuser webuser 116767 Nov 13 00:24 test_1112.tar.gz
#解压缩 -zxvf ls -l total 116 -rw-rw-rw-. 1 webuser webuser 116767 Nov 13 00:24 test_1112.tar.gz tar -zxvf test_1112.tar.gz test_1112/ test_1112/hero1.png test_1112/hero.png test_1112/hero2.png ls -l total 120 drwxrwxrw-. 2 webuser webuser 4096 Nov 13 00:12 test_1112 -rw-rw-rw-. 1 webuser webuser 116767 Nov 13 00:24 test_1112.tar.gz
#跳过文件 --exclude fileName ls -l test_1112/ total 120 -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:05 hero1.png -rw-rw-r--. 1 webuser webuser 38879 Nov 13 00:06 hero2.png -rw-rw-r--. 1 webuser webuser 38879 Oct 8 14:13 hero.png tar -cvf test_1112.tar test_1112 --exclude hero.png --exclude hero1.png test_1112/ test_1112/hero2.png tar -tf test_1112.tar test_1112/ test_1112/hero2.png