zoukankan      html  css  js  c++  java
  • 十二 Linux之tar解压缩

      tar是常用的解压缩指令,常用参数

    • -c 创建一个压缩包
    • v 显示压缩的详细信息
    • -z 压缩,如果没有只是打包
    • -f 压缩后的目标文件名
    • -x解压
    • -C解压到指定目录下

    实例

    1. 把所有名为cc*.txt的文件打包到file.tar下
      [root@centoscc cc]# tar -cf file.tar cc*.txt
      [root@centoscc cc]# ls -l
      总用量 60
      ...
      -rw-r--r--. 1 root root  10240 12月 24 19:11 file.tar
      ...
    2. 把文件root1.txt增加到file.tar文件中
      [root@centoscc cc]# tar -rf file.tar root1.txt
    3. 更新file.tar包中的root1.txt文件
      [root@centoscc cc]# tar -uf file.tar root1.txt
    4. 列出包中的文件
      [root@centoscc cc]# tar -tf file.tar
      cc4.txt
      cc.txt
      root1.txt
    5. 解出包中内容到同一目录下
      [root@centoscc cc1]# ls -l
      总用量 12
      drwx--x--x. 3 root root    18 12月 20 16:25 cc1
      drwxr-xr-x. 2 root root     6 12月 20 16:24 cc11
      -rw-r--r--. 1 root root 10240 12月 24 19:11 file.tar
      [root@centoscc cc1]# tar -xf file.tar
      [root@centoscc cc1]# ls -l
      总用量 24
      drwx--x--x. 3 root root    18 12月 20 16:25 cc1
      drwxr-xr-x. 2 root root     6 12月 20 16:24 cc11
      -rw-r--r--. 1 root root    16 12月 20 21:19 cc4.txt
      -rw-r--r--. 1 root root    15 12月 20 21:21 cc.txt
      -rw-r--r--. 1 root root 10240 12月 24 19:11 file.tar
      -rw-r--r--. 1 root root    16 12月 22 20:37 root1.txt
    6. 解出包中内容到指定目录下(该目录要先创建,否则会报错)
      [root@centoscc cc1]# tar -xvf file.tar -C file1
      cc4.txt
      cc.txt
      root1.txt
      [root@centoscc cc1]# cd file1
      [root@centoscc file1]# ls -l
      总用量 12
      -rw-r--r--. 1 root root 16 12月 20 21:19 cc4.txt
      -rw-r--r--. 1 root root 15 12月 20 21:21 cc.txt
      -rw-r--r--. 1 root root 16 12月 22 20:37 root1.txt

    tar调用其他压缩程序

    常用指令:

    • z:把tar包压缩成.tar.gz格式:

      # tar -czf file1.tar.gz cc*.txt   解压:# tar -xzf file1.tar.gz 

    • Z:把tar包压缩成.tar.Z
    • j:把tar包压缩成 .tar.bz2
  • 相关阅读:
    程灵素:我走过山的时候山不说话
    编译原理自学计划
    由一个虚构的例子谈谈中小型研发型项目的技术管理及成本控制(全文)
    用3种IDE导入Linux 2.26 内核源码
    Web风行者的设计方案与计划
    使用pyste自动生成c++类的python wrapper
    让log4cpp日志文件超过2G(Linux下)的方法
    python绑定c++程序
    网络风行者(KSpider)的规则体系结构
    检测您的浏览器是否支持 HTML5 视频方法
  • 原文地址:https://www.cnblogs.com/Cc905/p/14185962.html
Copyright © 2011-2022 走看看