zoukankan      html  css  js  c++  java
  • linux指令tar笔记

    tar 工具常用选项如表所列。

    选项  说明
    -c  创建存档文件,与-x相斥
    -t  列出档案文件的文件列表
    -x  解包存档文件,与-c相斥
    -A  合并存档文件
    -d  比较存档文件与源文件
    -r  追加文件到存档文件末尾
    -u  更新存档文件
    -f  指定存档文件,与其它选项同时使用时,必须在最后,如 tar -xjvf a.tar.bz2
    -v  显示详细处理信息
    -C  转到指定目录,常用于解开存档文件
    -j  调用 bzip2 程序
    -z  调用 gzip 程序
    -Z  调用 compress 程序
    --exclude=PATH  排除指定文件/目录,常用于打包文件

    使用示例:
    (1)解压 a.tar.bz2 文件,并显示详细信息:
     tar -xjvf a.tar.bz2
    (2)解压 b.tar.gz 文件,并指定解压到/home/temp/目录:
     tar -xzvf b.tar.gz -C /home/temp
    (3)将 drivers 目录的文件打包,创建一个.tar.bz2 压缩文件:
     tar -cjvf drivers.tar.bz2 drivers

    打包:
    zip   gzip  bzip2 tar  xz     //rar

    zip 包
    zip   xxx.zip     test.c  压缩
    unzip  xxx.zip             解压    解压之后还有压缩包

    gzip
    gzip   test.c        ==>    test.c.gz   压缩
    gunzip   test.c.gz   ==>   test.c    解压   解压后没有压缩包

    bzip2
    bzip2  test.c        ==>    test.c.bz2  压缩   
    bunzip2   test.c.bz2 ==>    test.c   解压   解压后没有压缩包

    xz
    xz     test.c        ==>    test.c.xz
    xz  -d test.c.xz    ==>    test.c
    unxz   test.c.xz     ==>   test.c   解压   解压后没有压缩包

    打包
    tar
    tar    -cf   test.c.tar  test.c      ==>   test.c.tar
    tar    -cvf  test.c.tar  test.c      ==>   test.c.tar
    c  ==> create
    f  ==> file

    tar   -xvf   test.c.tar      ==>  test.c
         -xf                    ==>   test.c

    x  ==> uncompress
    v  ==> view       能看到解压或者压缩的过程

    复合型
    aaa.tar.xz    aaa.tar.bz2   aaa.tar.gz

    打成  aaa.tar.gz
    tar  -czvf   aaa.tar.gz  aaa    ==> 生成aaa.tar.gz
    tar  -xzvf   aaa.tar.gz          ==>  aaa 解压   解压后有压缩包

    tar  -cjvf   aaa.tar.bz2  aaa   ==>  aaa.tar.bz2
    tar  -xjvf   aaa.tar.bz2         ==> aaa


    xz压包
    tar  -cvf   aaa.tar  aaa   ==>  aaa.tar
    xz  aaa.tar                 ==>  aaa.tar.xz

    unxz  aaa.tar.xz            ==>  aaa.tar
    tar  -xvf aaa.tar          ==>  aaa

  • 相关阅读:
    for循环的执行循序
    final和finally面试时最好的回答
    关于java类加载器的一些概念
    JVM内存分析
    建造者模式
    外观模式
    常用的设计模式
    Java基础知识:Java实现Map集合二级联动3
    Java基础知识:Java实现Map集合二级联动1
    MySQL数据库怎么截取字符串?
  • 原文地址:https://www.cnblogs.com/libra13179/p/10119342.html
Copyright © 2011-2022 走看看