国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學習啦 > 學習電腦 > 操作系統 > Linux教程 > linux中的tar命令(2)

    linux中的tar命令(2)

    時間: 佳洲1085 分享

    linux中的tar命令

      實例4:只將 /tar 內的 部分文件解壓出來

      命令:

      tar -zxvf /opt/soft/test/log30.tar.gz log2013.log

      輸出:

      [root@localhost test]# tar -zcvf log30.tar.gz log2012.log log2013.log

      log2012.log

      log2013.log

      [root@localhost test]# ls -al log30.tar.gz

      -rw-r--r-- 1 root root 1512 11-30 08:19 log30.tar.gz

      [root@localhost test]# tar -zxvf log30.tar.gz log2013.log

      log2013.log

      [root@localhost test]# ll

      -rw-r--r-- 1 root root 1512 11-30 08:19 log30.tar.gz

      [root@localhost test]# cd test3

      [root@localhost test3]# tar -zxvf /opt/soft/test/log30.tar.gz log2013.log

      log2013.log

      [root@localhost test3]# ll

      總計 4

      -rw-r--r-- 1 root root 61 11-13 06:03 log2013.log

      [root@localhost test3]#

      說明:

      我可以透過 tar -ztvf 來查閱 tar 包內的文件名稱,如果單只要一個文件,就可以透過這個方式來解壓部分文件!

      實例5:文件備份下來,并且保存其權限

      命令:

      tar -zcvpf log31.tar.gz log2014.log log2015.log log2016.log

      輸出:

      [root@localhost test]# ll

      總計 0

      -rw-r--r-- 1 root root 0 11-13 06:03 log2014.log

      -rw-r--r-- 1 root root 0 11-13 06:06 log2015.log

      -rw-r--r-- 1 root root 0 11-16 14:41 log2016.log

      [root@localhost test]# tar -zcvpf log31.tar.gz log2014.log log2015.log log2016.log

      log2014.log

      log2015.log

      log2016.log

      [root@localhost test]# cd test6

      [root@localhost test6]# ll

      [root@localhost test6]# tar -zxvpf /opt/soft/test/log31.tar.gz

      log2014.log

      log2015.log

      log2016.log

      [root@localhost test6]# ll

      總計 0

      -rw-r--r-- 1 root root 0 11-13 06:03 log2014.log

      -rw-r--r-- 1 root root 0 11-13 06:06 log2015.log

      -rw-r--r-- 1 root root 0 11-16 14:41 log2016.log

      [root@localhost test6]#

      說明:

      這個 -p 的屬性是很重要的,尤其是當您要保留原本文件的屬性時

      實例6:在 文件夾當中,比某個日期新的文件才備份

      命令:

      tar -N "2012/11/13" -zcvf log17.tar.gz test

      輸出:

      [root@localhost soft]# tar -N "2012/11/13" -zcvf log17.tar.gz test

      tar: Treating date `2012/11/13' as 2012-11-13 00:00:00 + 0 nanoseconds

      test/test/log31.tar.gz

      test/log2014.log

      test/linklog.log

      test/log2015.log

      test/log2013.log

      test/log2012.log

      test/log2017.log

      test/log2016.log

      test/log30.tar.gz

      test/log.tar

      test/log.tar.bz2

      test/log.tar.gz

      說明:

      實例7:備份文件夾內容是排除部分文件

      命令:

      tar --exclude scf/service -zcvf scf.tar.gz scf/*

      輸出:

      [root@localhost test]# tree scf

      scf

      |-- bin

      |-- doc

      |-- lib

      `-- service

      `-- deploy

      |-- info

      `-- product

      7 directories, 0 files

      [root@localhost test]# tar --exclude scf/service -zcvf scf.tar.gz scf/*

      scf/bin/

      scf/doc/

      scf/lib/

      [root@localhost test]#

      擴展資料:linux中的其他常見的壓縮解壓縮命令

      tar

      解包:tar xvf FileName.tar

      打包:tar cvf FileName.tar DirName

      (注:tar是打包,不是壓縮!)

      .gz

      解壓1:gunzip FileName.gz

      解壓2:gzip -d FileName.gz

      壓縮:gzip FileName

      .tar.gz 和 .tgz

      解壓:tar zxvf FileName.tar.gz

      壓縮:tar zcvf FileName.tar.gz DirName

      .bz2

      解壓1:bzip2 -d FileName.bz2

      解壓2:bunzip2 FileName.bz2

      壓縮: bzip2 -z FileName

      .tar.bz2

      解壓:tar jxvf FileName.tar.bz2

      壓縮:tar jcvf FileName.tar.bz2 DirName

      .bz

      解壓1:bzip2 -d FileName.bz

      解壓2:bunzip2 FileName.bz

      壓縮:未知

      .tar.bz

      解壓:tar jxvf FileName.tar.bz

      壓縮:未知

      .Z

      解壓:uncompress FileName.Z

      壓縮:compress FileName

      .tar.Z

      解壓:tar Zxvf FileName.tar.Z

      壓縮:tar Zcvf FileName.tar.Z DirName

      .zip

      解壓:unzip FileName.zip

      壓縮:zip FileName.zip DirName

      .rar

      解壓:rar x FileName.rar

      壓縮:rar a FileName.rar DirName

    3626346