再Linux下使用Tar工具歸檔檔案的教程

來源:互聯網
上載者:User

   Tar 由 'Tape archiver(磁帶歸檔器)' 衍生而來,最初被用來在磁帶上歸檔和隱藏檔。Tar 是一個 GNU 軟體,它可以壓縮一組檔案(歸檔),或提取它們以及對已有的歸檔檔案進行相關操作。在儲存、備份以及傳輸檔案方面,它是很有用的。在建立歸檔檔案時,Tar 可以保持原有檔案和目錄結構不變。通過 Tar 歸檔的檔案的尾碼名為 ‘.tar’。

  基本用法如下:

  a) 建立歸檔 (c / --create)

  代碼如下:

  tar --create --verbose --file=archive.tar file1 file2 file3

  或

  代碼如下:

  tar cvf archive.tar file1 file2 file3

  建立一個歸檔

  b) 列出歸檔檔案內容 ( t / --list)

  代碼如下:

  tar --list archive.tar

  列出歸檔中包含的檔案

  c) 提取歸檔 (x / --extract)

  代碼如下:

  tar xvf archive.tar

  tar xvf archive.tar --wildcards '*.c'

  - 從歸檔中提取尾碼名為 *.c 的檔案。

  提取檔案

  只提取需要的檔案

  d) 對歸檔檔案進行更新 ( u / --update)

  代碼如下:

  tar uvf archive.tar newfile.c

  - 假如歸檔的newfile.c 要比先前已經歸檔的新,則添加更新的 newfile.c 到歸檔裡面.

  更新一個歸檔

  e) 從歸檔中刪除檔案 (--delete)

  代碼如下:

  tar --delete -f archive.tar file1.c

  - 從壓縮包'archive.tar' 中刪除檔案'file1.c'

  刪除檔案

  更加具體的使用方法請參考tar 首頁。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.