4-11 Linux中的打包和备份的归档工具 --- tar(打

2021-09-30  本文已影响0人  捌千里路雲和月
[root@localhost ~]# mkdir test          ##  root 的家目录下创建 test 目录
[root@localhost ~]# 
[root@localhost ~]# cd test/            ## 进入 test 目录
[root@localhost test]# 
[root@localhost test]# mkdir SRC        ## test 目录下创建 SRC 目录,作为源目录
[root@localhost test]# 
[root@localhost test]# mkdir backups_tar      ## test 目录下创建 backups_tar 目录,作为目标目录
[root@localhost test]# 
[root@localhost test]# cd SRC/          ## 进入 SRC 目录
[root@localhost SRC]# 
[root@localhost SRC]# mkdir directory    ## SRC 目录下创建 directory目录
[root@localhost SRC]# cd directory/      ## 进入 directory
[root@localhost directory]# 

## dircetory 目录下创建 file1.txt、file2.txt 和 file3.txt
[root@localhost directory]# touch file1.txt file2.txt file3.txt    
[root@localhost directory]# 
[root@localhost directory]# cd /root/test/    ##  切换到 test 目录
[root@localhost test]# 
[root@localhost test]# tree                   ## 查看 test 目录下的结构
.
├── backups_tar
└── SRC
    └── directory
        ├── file1.txt
        ├── file2.txt
        └── file3.txt

3 directories, 3 files
[root@localhost test]# 

2、用参数 -cvf 打包 directory 目录及内容。

[root@localhost ~]# 
[root@localhost ~]# tree    ## 首先从家目录开始查看目录结构,定位 directory 目录位置
.
└── test
    ├── backups_tar
    └── SRC
        └── directory       ## directory 目录在 test/SRC下
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files
[root@localhost ~]# 
[root@localhost ~]# cd test/SRC/    ## 进入test/SRC/ 目录
[root@localhost SRC]# 
[root@localhost SRC]# ll
total 0
drwxr-xr-x. 2 root root 57 Sep 10 12:59 directory

## tar:打包命令。
## -cvf:c  创建文档、v  显示详情、f  打包的文件名。
## directory_bak.tar:生成的打包文件名称。
## directory/:打包的目录。

[root@localhost SRC]# tar cvf directory_bak.tar directory/
directory/            ## 打包输出的信息。打包了 directory 目录以及目录下的文件
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost SRC]# 
[root@localhost SRC]# ll    ## SRC目录下生成了刚才打包的文件 directory_bak.tar 
total 12
drwxr-xr-x. 2 root root    57 Sep 10 12:59 directory
-rw-r--r--. 1 root root 10240 Sep 10 14:26 directory_bak.tar    ## 打包文件
[root@localhost SRC]# 
[root@localhost SRC]# cd    ## 切换到家目录
[root@localhost ~]# 
[root@localhost ~]# tree  ## 查看目录结构
.
└── test
    ├── backups_tar
    └── SRC
        ├── directory
        │   ├── file1.txt
        │   ├── file2.txt
        │   └── file3.txt
        └── directory_bak.tar    ## 打包文件

4 directories, 4 files
[root@localhost ~]# 

3、用参数 tf 列出包内容。tvf 列出包详细内容

##  tf
[root@localhost ~]# tar tf test/SRC/directory_bak.tar 
directory/
directory/file1.txt
directory/file2.txt
directory/file3.txt

##  tvf 
[root@localhost ~]# tar tvf test/SRC/directory_bak.tar 
drwxr-xr-x root/root         0 2021-09-10 12:59 directory/
-rw-r--r-- root/root         0 2021-09-10 11:11 directory/file1.txt
-rw-r--r-- root/root         0 2021-09-10 11:11 directory/file2.txt
-rw-r--r-- root/root         0 2021-09-10 11:11 directory/file3.txt
[root@localhost ~]# 

4、解包用 xvf 参数。

## 当前目录在 root 家目录,用 tree 查看一下目录结构。
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    └── SRC
        ├── directory
        │   ├── file1.txt
        │   ├── file2.txt
        │   └── file3.txt
        └── directory_bak.tar    ## 包在 SRC 目录下

4 directories, 4 files
[root@localhost ~]# 
[root@localhost ~]# rm -rf test/SRC/directory    ## 删除原有的 directory的目录,方便观察

[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    └── SRC
        └── directory_bak.tar    ## 包在 SRC 目录下

3 directories, 1 file
[root@localhost ~]# 
[root@localhost ~]# tar xvf test/SRC/directory_bak.tar    ## 当前目录 root下解包 
directory/
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── directory    ## directory 目录及内容解包出来
│   ├── file1.txt
│   ├── file2.txt
│   └── file3.txt
└── test
    ├── backups_tar
    └── SRC
        └── directory_bak.tar

4 directories, 4 files
[root@localhost ~]# 
[root@localhost ~]# ll
total 0
drwxr-xr-x. 2 root root 57 Sep 10 12:59 directory    ## directory 目录
drwxr-xr-x. 4 root root 36 Sep 11 08:53 test
[root@localhost ~]# 

5、打包、解包细节事项:

## 当前位置在 root 目录下。 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    └── SRC
        └── directory    ## directory 目录所在之处
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files

##  在当前目录下执行 tar,打包位置就会在当前目录。 (当前位置是 root )
[root@localhost ~]# tar cvf directory.tar test/SRC/directory/
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── directory.tar    ## 包所在的位置是 root目录下
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
[root@localhost ~]# 
[root@localhost ~]# ll
total 12
-rw-r--r--. 1 root root 10240 Sep 12 21:14 directory.tar
drwxr-xr-x. 4 root root    36 Sep 12 20:30 test
[root@localhost ~]# 

[root@localhost ~]# cd test/    ## 切换到 test目录执行 tar 打包 directory 目录
[root@localhost test]#
[root@localhost test]# tar cvf directory.tar SRC/directory/
SRC/directory/
SRC/directory/file1.txt
SRC/directory/file2.txt
SRC/directory/file3.txt
[root@localhost test]# 
[root@localhost test]# cd 
[root@localhost ~]# tree
.
├── directory.tar
└── test
    ├── backups_tar
    ├── directory.tar    ## test 目录下执行的 tar 打包命令生成的包
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 5 files
[root@localhost ~]# 


2)、如果想把打包文件存放到其他地方,就要指定打包路径存放 tar 的打包文件。
例:把 directory 目录及文件打包到 backups_tar 目录。

[root@localhost ~]# tree
.
└── test
    ├── backups_tar    ## backups_tar 在 /root/test/ 目录下
    └── SRC
        └── directory    ## directory 在 /root/test/SRC 目录下
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files
[root@localhost ~]# 

##  切换到 backups_tar 目录
[root@localhost ~]# cd test/backups_tar/

## 当前目录下执行 tar 对 directory 目录的打包
[root@localhost backups_tar]# tar cvf directory.tar /root/test/SRC/directory/
tar: Removing leading `/' from member names    ## 绝对路径指向源目录会出这个提示。    
/root/test/SRC/directory/
/root/test/SRC/directory/file1.txt
/root/test/SRC/directory/file2.txt
/root/test/SRC/directory/file3.txt
[root@localhost backups_tar]# 
[root@localhost backups_tar]# cd
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar    ## backups_tar 目录生成 tar 包
    │   └── directory.tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
[root@localhost ~]# 

路径图示
[root@localhost ~]# 
[root@localhost ~]# cd test/backups_tar/

## cvPf 参数进行 tar 打包
[root@localhost backups_tar]# tar cvPf directory.tar /root/test/SRC/directory/
/root/test/SRC/directory/
/root/test/SRC/directory/file1.txt
/root/test/SRC/directory/file2.txt
/root/test/SRC/directory/file3.txt
[root@localhost backups_tar]# 
[root@localhost backups_tar]# cd
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    │   └── directory.tar    ## backups_tar 目录生成 tar 包
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
[root@localhost ~]# 

[root@localhost ~]# tree    ## 没有打包时的目录结构
.
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files


## test/backups_tar/directory.tar 存放 tar 的目录,并且命名 tar包
## test/SRC/directory/  源目录(需要打包的目录)
[root@localhost ~]# tar cvf test/backups_tar/directory.tar test/SRC/directory/
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    │  └── directory.tar    ## backups_tar 目录下生成了 directory.tar 包
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
[root@localhost ~]# 

tar 打包到指定目录图解

3)、精确定位打包到单个目录或目录下的文件。

[root@localhost ~]# tar cvf test/backups_tar/directory.tar test/SRC/directory/
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost ~]# 

[root@localhost ~]# cd test/backups_tar/    ## 却换到 backups_tar目录
[root@localhost backups_tar]# 
[root@localhost backups_tar]# tar xvf directory.tar    解包 directory.tar
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost backups_tar]# 
[root@localhost backups_tar]# cd    ## 切换回去 root 目录下查看结构数
[root@local树ost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    │   ├── directory.tar
    │   └── test                  ## 解包出来的路径及层级
    │       └── SRC
    │           └── directory
    │               ├── file1.txt
    │               ├── file2.txt
    │               └── file3.txt
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

7 directories, 7 files
[root@localhost ~]# 

[root@localhost ~]# tar cvf test/backups_tar/directory.tar -C test/SRC/ directory/    ## directory/ 前面有空格 
directory/              ## 打包的信息是 directory 目录及递归的内容
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    │   └── directory.tar    ## 生成的 tar 包
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
[root@localhost ~]# 

[root@localhost ~]# 
[root@localhost ~]# cd test/backups_tar/    ## 切换到 backups_tar目录
[root@localhost backups_tar]# 
[root@localhost backups_tar]# tar xvf directory.tar     ## 解包 directory.tar
directory/
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost backups_tar]# 
[root@localhost backups_tar]# cd    
[root@localhost ~]# 
[root@localhost ~]# tree    ## 切换到 root 目录列出树形结构查看层级
.
└── test
    ├── backups_tar
    │   ├── directory    ## directory.tar 解包出来的内容就是 directory 目录及递归的内容
    │   │   ├── file1.txt
    │   │   ├── file2.txt
    │   │   └── file3.txt
    │   └── directory.tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

5 directories, 7 files
[root@localhost ~]# 

[root@localhost ~]# 
[root@localhost ~]# tree    ##  初始的目录结构
.
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files

## 打包 directory 下的文件到 backups_tar 下,
## -C test/SRC/directory/ .  
## 指定 directory 目录下的位置,注意后面是 空格 还有 . 一点。

[root@localhost ~]# tar cvf test/backups_tar/directory.tar -C test/SRC/directory/ .
./
./file1.txt
./file2.txt
./file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    │   └── directory.tar    ## 包已生成
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files

##  下面是切换到  backups_tar 解包 directory.tar 

[root@localhost ~]# cd test/backups_tar/
[root@localhost backups_tar]# 
[root@localhost backups_tar]# tar xvf directory.tar 
./
./file1.txt
./file2.txt
./file3.txt
[root@localhost backups_tar]# 
[root@localhost backups_tar]# cd
[root@localhost ~]#  tree
.
└── test
    ├── backups_tar
    │   ├── directory.tar
    │   ├── file1.txt    ##  directory.tar 解包出来是 directory 目录下的文件
    │   ├── file2.txt
    │   └── file3.txt
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 7 files
[root@localhost ~]# 


4)、指定打包某些目录、文件。假设 SRC 目录下有多个目录及不同类型的文件需要进行打包。

[root@localhost ~]# tree    ## 初始目录结构
.
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files

## 新建 office_directory 和 photo_directory 目录
[root@localhost ~]# mkdir test/SRC/office_directory ; mkdir test/SRC/photo_directory

## office_directory 目录创建 .docx、.xlsx 和 .pdf 文件
[root@localhost ~]# touch test/SRC/office_directory/mon.docx test/SRC/office_directory/tue.docx
[root@localhost ~]# touch test/SRC/office_directory/wed.xlsx test/SRC/office_directory/thu.xlsx
[root@localhost ~]# touch test/SRC/office_directory/fri.pdf test/SRC/office_directory/sat.pdf

## photo_directory 目录创建  .jpg 、.bmg 和 .png 的文件
[root@localhost ~]# touch test/SRC/photo_directory/mon.jpg test/SRC/photo_directory/tue.jpg
[root@localhost ~]# touch test/SRC/photo_directory/wed.bmg test/SRC/photo_directory/thu.bmg
[root@localhost ~]# touch test/SRC/photo_directory/fri.png test/SRC/photo_directory/sat.png
[root@localhost ~]# 
[root@localhost ~]# tree    ## 新增测试用例的目录结构
.
└── test
    ├── backups_tar
    └── SRC
        ├── directory
        │   ├── file1.txt
        │   ├── file2.txt
        │   └── file3.txt
        ├── office_directory
        │   ├── fri.pdf
        │   ├── mon.docx
        │   ├── sat.pdf
        │   ├── thu.xlsx
        │   ├── tue.docx
        │   └── wed.xlsx
        └── photo_directory
            ├── fri.png
            ├── mon.jpg
            ├── sat.png
            ├── thu.bmg
            ├── tue.jpg
            └── wed.bmg

6 directories, 15 files
[root@localhost ~]# 

## 首先,创建一个目录保存需要打包的文件
[root@localhost ~]# mkdir backups_file

## rsync 同步 file2.txt 到 backups_file 目录
[root@localhost ~]# rsync -av test/SRC/directory/file2.txt backups_file/
sending incremental file list
file2.txt

sent 85 bytes  received 35 bytes  240.00 bytes/sec
total size is 0  speedup is 0.00

## rsync 同步所有 .pdf 结尾的文件到 backups_file 目录
[root@localhost ~]# rsync -av test/SRC/office_directory/*.pdf backups_file/
sending incremental file list
fri.pdf
sat.pdf

sent 146 bytes  received 54 bytes  400.00 bytes/sec
total size is 0  speedup is 0.00

## rsync 同步所有 .jpg结尾的文件到 backups_file 目录
[root@localhost ~]# rsync -av test/SRC/photo_directory/*.jpg backups_file/
sending incremental file list
mon.jpg
tue.jpg

sent 146 bytes  received 54 bytes  400.00 bytes/sec
total size is 0  speedup is 0.00
[root@localhost ~]# 
[root@localhost ~]# ll backups_file/    ## 所有需要打包的文件都放到了 backups_file 目录下。
total 0
-rw-r--r--. 1 root root 0 Sep  9 20:52 file2.txt
-rw-r--r--. 1 root root 0 Sep 14 21:26 fri.pdf
-rw-r--r--. 1 root root 0 Sep 14 21:28 mon.jpg
-rw-r--r--. 1 root root 0 Sep 14 21:26 sat.pdf
-rw-r--r--. 1 root root 0 Sep 14 21:28 tue.jpg
[root@localhost ~]# 

[root@localhost ~]# tar cvf test/backups_tar/backups_file.tar backups_file/
backups_file/
backups_file/file2.txt
backups_file/fri.pdf
backups_file/sat.pdf
backups_file/mon.jpg
backups_file/tue.jpg

## 解包 backups_file.tar 到 backups_tar 目录
[root@localhost ~]# tar xvf test/backups_tar/backups_file.tar -C test/backups_tar/
backups_file/
backups_file/file2.txt
backups_file/fri.pdf
backups_file/sat.pdf
backups_file/mon.jpg
backups_file/tue.jpg
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── backups_file
│   ├── file2.txt
│   ├── fri.pdf
│   ├── mon.jpg
│   ├── sat.pdf
│   └── tue.jpg
└── test
    ├── backups_tar
    │   ├── backups_file    ## 解包结果和源打包目录一样
    │   │   ├── file2.txt
    │   │   ├── fri.pdf
    │   │   ├── mon.jpg
    │   │   ├── sat.pdf
    │   │   └── tue.jpg
    │   └── backups_file.tar
    └── SRC
        ├── directory
        │   ├── file1.txt
        │   ├── file2.txt
        │   └── file3.txt
        ├── office_directory
        │   ├── fri.pdf
        │   ├── mon.docx
        │   ├── sat.pdf
        │   ├── thu.xlsx
        │   ├── tue.docx
        │   └── wed.xlsx
        └── photo_directory
            ├── fri.png
            ├── mon.jpg
            ├── sat.png
            ├── thu.bmg
            ├── tue.jpg
            └── wed.bmg

8 directories, 26 files
[root@localhost ~]# 


[root@localhost ~]# tree    ## 初始目录结构
.
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt
[root@localhost ~]# cd test/SRC/    ## 切换到 SRC 目录

##  打包 directory 目录并用 --remove-file 参数删除源目录
[root@localhost SRC]# tar cvf directory.tar directory/ --remove-file    
directory/
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost SRC]# 
[root@localhost SRC]# cd    ## 切换到 root 目录查看目录结构
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    └── SRC                  ##  directory 已打包,源目录的 directroy 已删除
        └── directory.tar

3 directories, 1 file

## 解 directory.tar 包到 SRC 目录下,查看包内容是否完整。
[root@localhost ~]# tar xvf test/SRC/directory.tar -C test/SRC/    
directory/
directory/file1.txt
directory/file2.txt
directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
└── test
    ├── backups_tar
    └── SRC
        ├── directory        ## 解 directory.tar 包的内容和源一样
        │   ├── file1.txt
        │   ├── file2.txt
        │   └── file3.txt
        └── directory.tar

4 directories, 4 files
[root@localhost ~]# 


6)、--exclude:排除指定目录或文件不进行打包。

##  打包 test 目录用 -exclude 参数排除 backups_tar 目录
[root@localhost ~]# tar cvf test.tar --exclude=backups_tar test/
test/
test/SRC/
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── test
│   ├── backups_tar
│   └── SRC
│       └── directory
│           ├── file1.txt
│           ├── file2.txt
│           └── file3.txt
└── test.tar              ## 生成 test.tar 包

4 directories, 4 files

## 解 test.tar 包到 backups_tar 目录下,查看包内容是否排除了 backups_tar 目录。
[root@localhost ~]# tar xvf test.tar -C test/backups_tar/
test/
test/SRC/
test/SRC/directory/
test/SRC/directory/file1.txt
test/SRC/directory/file2.txt
test/SRC/directory/file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── test
│   ├── backups_tar
│   │   └── test                    ## 解包出来的 test 目录下没有 backups_tar 目录,符合要求
│   │       └── SRC
│   │           └── directory
│   │               ├── file1.txt
│   │               ├── file2.txt
│   │               └── file3.txt
│   └── SRC
│       └── directory
│           ├── file1.txt
│           ├── file2.txt
│           └── file3.txt
└── test.tar

7 directories, 7 files
[root@localhost ~]# 

[root@localhost ~]# tree    ## 初始目录结构
.
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 3 files
## 打包 directory 目录下的文件,用 -exclude 参数排除 file2.txt 文件不打包。
[root@localhost ~]# tar cvf file.tar --exclude=file2.txt -C test/SRC/directory/ .
./
./file1.txt
./file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── file.tar              ## 生成 file.tar 包
└── test
    ├── backups_tar
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 4 files
## 解 file.tar 包到 backups_tar 目录下,查看包内容是否排除了 file2.txt 文件。
[root@localhost ~]# tar xvf file.tar -C test/backups_tar/
./
./file1.txt
./file3.txt
[root@localhost ~]# 
[root@localhost ~]# tree
.
├── file.tar
└── test
    ├── backups_tar    ## 解包出来的 文件没有 file2.txt,符合要求
    │   ├── file1.txt
    │   └── file3.txt
    └── SRC
        └── directory
            ├── file1.txt
            ├── file2.txt
            └── file3.txt

4 directories, 6 files
[root@localhost ~]# 

## 多个 exclude 分别标注多个单一的条件
[root@localhost ~]# 
[root@localhost ~]# tar cvf file.tar --exclude=file1.txt --exclude=file3.txt -C test/SRC/directory/ .
./
./file2.txt

##  exclude { } 标注多个条件,每个条件用 , 逗号隔开
[root@localhost ~]# 
[root@localhost ~]# tar cvf file.tar --exclude={file1.txt,file3.txt} -C test/SRC/directory/ .
./
./file2.txt
[root@localhost ~]# 


## 也把需要排除的条件写到文档中,然后用 --exclude-frmo 导入文件,通过文件的内容进行排除。
[root@localhost ~]# vim exclude-file

file1.txt
file3.txt
~                                                                                                      
~                                                                                                                                                                                                     
~                                                                                                      
:wq  

[root@localhost ~]# 
[root@localhost ~]# tar cvf file.tar --exclude-from='exclude-file' -C test/SRC/directory/ .
./
./file2.txt
[root@localhost ~]# 

上一篇下一篇

猜你喜欢

热点阅读