乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      15+ 個(gè) tar 命令的用法,附示例

       昵稱15574459 2014-03-10

       tar 命令用來(lái)將很多文件打包成一個(gè)單一的磁帶或者磁盤歸檔,并可從歸檔文件恢復(fù)出文件列表。當(dāng)你需要通過(guò) email 發(fā)送大量文件時(shí)或者傳輸文件時(shí)非常有用。這里我們介紹一些基本的使用場(chǎng)景。

      tar 的語(yǔ)法:

      1# tar [options] file.tar file1 file2 .. .. ..

      file.tar 是 tar 歸檔文件,而其他 file1 和 file2 等等是要被打包的文件。

      例如我們有兩個(gè)文件 file1.txt 和 file2.txt

      1[root@localhost TAR]# ll
      2total 8
      3-rw-r--r--. 1 root root 2770 Feb  7 22:37 file1.txt
      4-rw-r--r--. 1 root root  887 Feb  7 22:38 file2.txt

      tar 常用的使用場(chǎng)景

      創(chuàng)建一個(gè) tar 文件 語(yǔ)法:

      1# tar -cf archive.tar files .. ..

      示例:

      1[root@localhost TAR]# tar -cf file.tar file1.txt file2.txt
      2[root@localhost TAR]# ll file.tar
      3-rw-r--r--. 1 root root 10240 Feb  7 22:42 file.tar

      列出 tar 文件中的所有文件列表

      1# tar -tf archive.tar

      示例:

      1[root@localhost TAR]# tar -tf file.tar
      2file1.txt
      3file2.txt

      從 tar 中提取所有文件

      1tar -xf archive.tar

      示例

      1[root@localhost TAR]# tar -xf file.tar
      2[root@localhost TAR]# ll
      3total 20
      4-rw-r--r--. 1 root root  2770 Feb  7 22:37 file1.txt
      5-rw-r--r--. 1 root root   887 Feb  7 22:38 file2.txt
      6-rw-r--r--. 1 root root 10240 Feb  7 22:42 file.tar

      參數(shù)選項(xiàng)

      1, -v, –verbose
      verbosely list files processed:
      Syntax:
      List all files in an archive.tar verbosely:

      1tar -tvf archive.tar

      Example:

      1[root@localhost TAR]# tar -tvf file.tar
      2-rw-r--r-- root/root      2770 2014-02-07 22:37 file1.txt
      3-rw-r--r-- root/root       887 2014-02-07 22:38 file2.txt

      2, -c, –create
      創(chuàng)建新的歸檔文件

      3, -t, –list
      列出歸檔文件中的內(nèi)容

      4, -x, –extract, –get
      從歸檔中提取文件

      5, -d, –diff, –compare
      比較歸檔和文件系統(tǒng)的差異
      Example:

      01[root@localhost TAR]# tar -tf file.tar
      02file2.txt
      03file3.txt
      04file1.txt
      05[root@localhost TAR]# tar -df file.tar file1.txt file2.txt file4.txt
      06tar: file4.txt: Not found in archive
      07tar: Exiting with failure status due to previous errors
      08----Verbosely----
      09[root@localhost TAR]# tar -dvf file.tar file1.txt file2.txt
      10file2.txt
      11file1.txt
      12[root@localhost TAR]# tar -dvf file.tar file1.txt file2.txt file6.txt
      13file2.txt
      14file1.txt
      15tar: file6.txt: Not found in archive
      16tar: Exiting with failure status due to previous errors

      6, –delete
      從歸檔中刪除某文件
      示例:
      從歸檔 file.tar 中刪除 file1.txt

      1[root@localhost TAR]# tar --delete -f  file.tar  file1.txt
      2[root@localhost TAR]# tar -tf file.tar
      3file2.txt

      7, -r, –append
      追加文件到歸檔中
      示例:
      追加 file3.txt 到 file.tar

      1[root@localhost TAR]# tar -rf file.tar file3.txt
      2[root@localhost TAR]# tar -tf file.tar
      3file1.txt
      4file2.txt
      5file3.txt

      8, -A, –catenate, –concatenate
      將一個(gè)tar 歸檔追加到另外一個(gè)歸檔文件中
      創(chuàng)建另外一個(gè) tar 文件

      1[root@localhost TAR]# tar -cf archive.tar file1.txt file3.txt

      追加方法:

      1[root@localhost TAR]# tar -Af file.tar archive.tar
      2[root@localhost TAR]# tar -tf file.tar
      3file2.txt
      4file3.txt
      5file1.txt
      6file1.txt
      7file3.txt

      9, –test-label
      測(cè)試歸檔卷標(biāo)并退出

      10, -u, –update
      只追加最新的文件
      示例:

      1[root@localhost TAR]# tar -tf file.tar
      2file1.txt
      3file2.txt
      4[root@localhost TAR]# tar -uf file.tar file1.txt file3.txt file2.txt
      5[root@localhost TAR]# tar -tf file.tar
      6file1.txt
      7file2.txt
      8file3.txt

      11, -C, –directory=DIR
      更改目錄到 DIR

      例如:
      提取文件到另外一個(gè)目錄

      1[root@localhost TAR]# tar -xvf file.tar -C /root/TAR2
      2file1.txt
      3file2.txt
      4[root@localhost TAR]# cd -
      5/root/TAR2
      6[root@localhost TAR2]# ll
      7total 28
      8-rw-r--r--. 1 root root 23250 Feb  7 23:11 file1.txt
      9-rw-r--r--. 1 root root   887 Feb  7 22:38 file2.txt

      12, -p, –preserve-permissions
      抽取文件時(shí)保留原有的文件權(quán)限

      壓縮歸檔文件,使用 BZIP 和 GZIP 兩種方法

      跟壓縮相關(guān)的參數(shù)

      13, -j, –bzip2
      使用 bzip2 對(duì)歸檔進(jìn)行壓縮

      示例:

      1[root@localhost TAR]# tar -jcf file.tar.bz file2.txt file1.txt
      2[root@localhost TAR]# ll
      3total 128
      4-rw-r--r--. 1 root root 23250 Feb  7 23:11 file1.txt
      5-rw-r--r--. 1 root root   887 Feb  7 22:38 file2.txt
      6-rw-r--r--. 1 root root 30720 Feb  7 23:30 file.tar
      7-rw-r--r--. 1 root root  1797 Feb  7 23:42 file.tar.bz

      請(qǐng)看,上面的文件大小通過(guò) BZIP 降低到 1797 字節(jié)。

      14, -z, –gzip
      使用 gzip 壓縮歸檔

      示例:

      1[root@localhost TAR]# tar -zcf file.tar.gz file2.txt file1.txt
      2[root@localhost TAR]# ll
      3total 132
      4-rw-r--r--. 1 root root 23250 Feb  7 23:11 file1.txt
      5-rw-r--r--. 1 root root   887 Feb  7 22:38 file2.txt
      6-rw-r--r--. 1 root root 30720 Feb  7 23:30 file.tar
      7-rw-r--r--. 1 root root  1797 Feb  7 23:42 file.tar.bz
      8-rw-r--r--. 1 root root  1673 Feb  7 23:45 file.tar.gz
      就這些了!

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多