tar命令解压tar、 gz、bz2结尾的压缩包,-C 目标文件夹,-f 文件名,区别是bz2是 tar -j 而gz是-z

tar -zxvf VMwareTools-10.0.5-3228253.tar.gz -C /home/VMTools
tar -jxvf VMwareTools-10.0.5-3228253.tar.bz2 -C /home/VMTools
tar -zcvf gz_test.tar.gz ./test.txt ./test2.txt

上面是打包多个文件

 

下面是打包整个目录

tar -zcvf gz_test.tar.gz ./*

 

 

tar命令压缩打包文件到压缩包,打包test.txt和cmd两个文件到archive.tar,-f指定目标文件名,-c表示打包

tar -cf archive.tar test.txt cmd.txt

 

 

如果不解压,就只查看压缩包里的文件

tar -tf archive.tar

 

 

zip和unzip分别打包zip和解压unzip文件

[root@gpslave1 home]# unzip greenplum-db-5.10.2-rhel7-x86_64.zip
Archive:  greenplum-db-5.10.2-rhel7-x86_64.zip
  inflating: greenplum-db-5.10.2-rhel7-x86_64.bin  
[root@gpslave1 home]# ll
总用量 384496
drwxr-xr-x. 2 root    root            6 9月   1 23:14 cdrom
-rwxrwxrwx. 1 root    root           33 9月   2 17:45 cmd
drwx------. 2 gpadmin gpadmin        62 9月  28 23:29 gpadmin
-rwxr-xr-x. 1 root    root    197905185 8月  10 2018 greenplum-db-5.10.2-rhel7-x86_64.bin
-rwxr-xr-x. 1 root    root    195802895 10月  9 02:01 greenplum-db-5.10.2-rhel7-x86_64.zip
drwxr-xr-x. 2 root    root           76 9月   4 00:55 gz_test
-rw-r--r--. 1 root    root          112 9月   4 00:43 gz_test.tar.gz
-rwxrwxrwx. 1 root    root          113 9月   3 16:37 tar_test.tar
-rwxrwxrwx. 1 root    root            0 9月   2 17:44 test.txt
drwxr-xr-x. 3 root    root           34 9月   1 23:32 VMTools
drwxr-xr-x. 9 root    root          175 11月 11 2015 vmware-tools-distrib

 

 

参考:

https://jingyan.baidu.com/article/9080802238d21dfd91c80fd5.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-10-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案