Linux 中tar命令 打包、解包到指定目录

发布时间 2023-10-31 22:27:01作者: 小鲨鱼2018

 

001、打包只指定目录

[root@pc1 test]# ls
a.txt  b.map  c.ped  dir1
[root@pc1 test]# ls dir1/
[root@pc1 test]# tar -cf ./dir1/xx.tar a.txt b.map c.ped    ## 打包至指定的目录
[root@pc1 test]# ls
a.txt  b.map  c.ped  dir1
[root@pc1 test]# ls dir1/
xx.tar

 

002、解包至指定的目录

[root@pc1 test]# ls
a.txt  b.map  c.ped  dir1  xx.tar
[root@pc1 test]# ls dir1/
[root@pc1 test]# tar -xf xx.tar -C ./dir1/    ## 解包至指定目录
[root@pc1 test]# ls dir1/
a.txt  b.map  c.ped

 。