使用Linux命令行歸檔文件

存檔文件 (Archiving Files)

As we already understand what Compression (Compression techniques in Linux) is? We shall learn about Archives. We prefer compression as it is convenient to send file compressed through a network but sometimes it is not a smart way to compress the multiple files separately but as a single entity, we can sure compress multiple files in a single line but in the core, all files are compressed independently.

眾所周知, 什么是壓縮( Linux中的壓縮技術 ) ? 我們將學習檔案。 我們更喜歡壓縮,因為它可以方便地通過網絡發送壓縮文件,但有時并不是分開壓縮多個文件的明智之舉,但是作為單個實體,我們可以肯定在一行中壓縮多個文件,但在核心中,所有文件是獨立壓縮的。

Archiving is the solution to this problem. The UNIX utility to archive files is tar, that is TApeaRchive.

存檔是解決此問題的方法。 用于歸檔文件的UNIX實用程序是tar ,即TApeaRchive

Tar has 3 modes those are:

Tar有3種模式,分別是:

  1. Create: which is a new archive from a group of files

    創建:這是來自一組文件的新存檔

  2. Extract: means getting one or more files from the archive

    提取:表示從存檔中獲取一個或多個文件

  3. The list: which shows the content of the archive without extracting it.

    列表:顯示存檔的內容而不提取它。

Our operations and command for archiving includes above three modes and will discuss throughout this article.

我們的歸檔操作和命令包括上述三種模式,并將在本文中進行討論。

A tar file is also called a tarball, now let's dive into the practical thing.

tar文件也稱為tarball,現在讓我們深入了解實際情況。

示例1:創建模式 (Example 1: Create mode)

Archives in Linux 1

Explanation

說明

Creating a Tarball(at least) requires 2 options, here we used 'c' and 'f' :

創建一個Tarball (至少)需要兩個選項,這里我們使用了'c''f'

  • c: create an archive file

    c:創建一個存檔文件

  • f: tells tar to expect a file name as next argument.

    f:告訴tar將文件名作為下一個參數。

In line 1, we created the tar file with .tar extension and used a wildcard for all the files we have selected (multiple file name or both can be used).

在第1行中,我們創建了擴展名為.tartar文件,并對我們選擇的所有文件使用了通配符(可以使用多個文件名,也可以使用兩個文件名)。

tar command consists of:

tar命令包含:

    tar [options] tarname filename1 filename2 ...

The first option of tar always is its mode, here it was created ('c') then 'f' where we pass file names after the name ofthe tar file.

tar的第一個選項始終是它的模式,在這里先創建( 'c' ),然后創建'f' ,在此我們在tar文件名之后傳遞文件名。

In line 2, the size of includehelp.tar is slightly more than the files it contains, but it can be compressed either explicitly compressing it with gzip(or bzip2) or with tar itself.

在第2行中, includehelp.tar的大小略大于其包含的文件,但是可以使用gzip (或bzip2 )或tar本身對其進行顯式壓縮。

示例2:壓縮 (Example 2: Compressing)

Archives in Linux 2

Explanation

說明

In the above example, we used 3 option format of tar, for compression with achieving.

在上面的示例中,我們使用了tar的 3個選項格式,以實現 壓縮

In line 2, again the first option is to create mode, second one 'z' is for gzip (we can use 'j' for bzip2), and third for file argument. Format of compress tar with gzip is .tar.gz or .tgz(for bzip2, format will be .tar.bz or tbz).

在第2行中,第一個選項是創建模式,第二個“ z”用于gzip (我們可以將“ j”用于bzip2 ),第三個用于文件參數。 使用gzip壓縮tar的格式為.tar.gz.tgz (對于bzip2 ,格式為.tar.bztbz )。

示例3:列表模式 (Example 3: List mode)

Archives in Linux 3

In the above sample, the command used is:

在上面的示例中,使用的命令是:

    tar –tzvf  filename

Where, –t option is used for list files in archive and z for gzip (j for bzip2) and v is verbose that is whatever is happing will shown on screen and f for given filename includehelp.tar.gz (or .tbz).

其中, -t選項用于歸檔文件中的列表文件, z表示gzip ( j表示bzip2 ), v表示冗長 ,即屏幕上將顯示的內容是hap ,給定文件名 includehelp.tar.gz (或.tbz )將顯示f

Note:

注意:

Although the position of the option doesn't matter in Linux command line in case of tar command, we always need to keep –f option at the end because after f it expects a filename.

盡管在使用tar命令的情況下,選項的位置在Linux命令行中并不重要,但我們始終需要在最后保留–f選項,因為在f之后需要一個文件名。

Recommended Articles:

推薦文章:

  • Make Utility (MakeFile) in Linux

    在Linux中制作實用程序(MakeFile)

  • Compression techniques in Linux

    Linux中的壓縮技術

  • ZIP files on command line in Linux

    Linux中命令行上的ZIP文件

翻譯自: https://www.includehelp.com/linux/archiving-files-using-linux-command-line.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541601.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541601.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541601.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

http緩存機制之304狀態碼

在網上看到一篇關于解釋瀏覽器緩存更新機制304狀態碼的文章,里面說如果請求頭中的If-Modified-Since字段和If-None-Match字段的值分別和響應頭中的Last-Modified字段和Etag字段值一致,服務器就會返回304狀態碼(無響應體),瀏覽器就從本地讀取緩…

東北大學 計算機技術導師,報考東北大學 計算機技術 329分 求調劑相關專業

自薦類型:碩士自薦報考院校:東北大學報考專業:(專業碩士)計算機技術[085211]本科院校:沈陽工程學院本科專業:計算機科學與技術初試成績:總分:329政治:69 英語:71 …

c語言i++和++i程序_使用C ++程序修改鏈接列表的內容

c語言i和i程序Problem statement: 問題陳述: Given a linked list, you modified that linked list in such a way that the elements of the first half of that linked list are the difference of the first node to the last node and next node is the differ…

原生js設置div隱藏或者顯示_10種JS控制DIV的顯示隱藏代碼

div隱藏與顯示#menus {background-color: #c4cff0;}function Layer_HideOrShow(cur_div){ var currentdocument.getElementById(cur_div);if(current.style.visibility"hidden"){current.style.visibility "visible";}else{current.style.visibility "…

計算機工作對身體有害嗎,在電腦前長時間工作會對身體有害處嗎?

病情分析:目前,電腦對人體生理和心理方面的負面影響已日益受到人們的重視.為此科學使用電腦,減少電腦和網絡的危害是十分必要的.指導意見:一是要增強自我保健意識工作間隙注意適當休息,一般來說,電腦操作人員在連續工作1小時后應該休息10分鐘左右.并且最…

Java LinkedList getFirst()方法與示例

LinkedList getFirst()方法 (LinkedList getFirst() method) This method is available in package java.util.LinkedList. 軟件包java.util.LinkedList中提供了此方法。 This method is used to return the first or initial or beginning element of the linked list. 此方法…

C++第15周(春)項目2 - 用文件保存的學生名單

課程首頁在:http://blog.csdn.net/sxhelijian/article/details/11890759。內有完整教學方案及資源鏈接本程序中須要的相關文件。請到http://pan.baidu.com/s/1qW59HTi下載。【項目2-用文件保存的學生名單】  文件score.dat中保存的是若干名學生的姓名和C課、高數和…

計算機選配 注意事項,選擇鼠標注意事項有哪些

選擇鼠標注意事項有哪些每臺電腦旁邊都有了一個忠實的伴侶,那就是“Mouse”--鼠標。選擇鼠標最重要的一點就是質量,無論它的功能有多強大、外形多漂亮,如果質量不好那么一切都不用考慮了。那么,選擇鼠標注意事項有哪些?筆記本鼠標…

js 驗證護照_護照本地策略第2部分| Node.js

js 驗證護照In my last article (Passport local strategy section 1 | Node.js), we started the implementation of the passport-local authentication strategy. We also looked at the various requirements to get started with the login form. In this article, we wil…

svn版利用什么技術實現_金蔥粉涂料印花利用了什么技術?

金蔥粉涂料印花利用了什么技術:金蔥粉用涂料而不是用染料來生產印花布已經非常廣泛,以致開始把它當作一種獨立的印花方式。涂料印花是用涂料直接印花,該工藝通常叫做干法印花,以區別于濕法印花(或染料印花)。通過比較同一塊織物上印花部位和未…

網站換服務器需要注意什么問題,網站更換服務器要注意哪些事項

原標題:網站更換服務器要注意哪些事項網站在運營的過程中,出于某種考慮,我們會將網站進行服務器的變更,那么在進行服務器變成過程中,需要注意哪些事項。一、如果是跨服務商更換網站服務器,需要做備案遷移。…

json轉string示例_C.示例中的String.Insert()方法

json轉string示例C#String.Insert()方法 (C# String.Insert() Method) String.Insert() method is used to insert a string in an existence string at specified index and returns a new string. String.Insert()方法用于在指定索引處的存在字符串中插入一個字符…

kafka分區與分組原理_大數據技術-Kafka入門

在大數據學習當中,主要的學習重點就是大數據技術框架,針對于大數據處理的不同環節,需要不同的技術框架來解決問題。以Kafka來說,主要就是針對于實時消息處理,在大數據平臺當中的應用也很廣泛。大數據學習一般都有哪些內…

mac 電腦找不到服務器 dns 地址,MAC OS下如何快速設置DNS服務器地址

樓主你好!介紹以下Mac OS X DNS設置方法:1、點擊桌面頂部狀態欄里的蘋果圖標,在菜單里選擇“系統偏好設置”。2、點擊互聯網與無線下的“網絡”。3、在網絡界面,選中正在聯網的網絡連接,點擊右下角的“高級”選項。4、…

ActiveReports 報表控件官方中文新手教程 (1)-安裝、激活以及產品資源

本系列文章主要是面向初次接觸 ActiveReports 產品的用戶,能夠幫助您在三天之內輕松的掌握ActiveReports控件的基本用法,包含安裝、激活、創建報表、綁定數據源以及公布等內容。本篇文章我們就從安裝產品開始帶您開啟輕松的 Ac…

如何在React Native中使用React JS Hooks?

In my articles, Im going to be using either expo or snack online IDE and android emulator. 在我的文章中,我將使用expo或點心在線IDE和android模擬器。 React Hooks is simply an awesome tool that helps us use states and other react features without w…

華為P40pro 手機云臺_2020年目前拍照最好的手機推薦!華為P40 Pro!DXO全球榜首

目前最熱門的拍照手機自然是華為P40 Pro,其相機性能直接問鼎DXOMARK手機相機評分榜首。對于拍照要極求高的用戶,華為P40 Pro將是一個非常不錯的選擇。那么,華為P40 Pro除了出色的相機之外,其它方面表現如何呢?下面&…

容器性能比無容器服務器,【譯】容器 vs 無服務器(Serverless)

一些歷史不久之前,開發,部署和運維還相當復雜。在一開始,運維不僅需要修補程序代碼,還要支持物理機器。保持服務器,硬件與軟件處于最新狀態也是一項艱巨的任務。在2000年代,一個新的模型——架構即服務(Iaa…

Centos 7安裝與配置nagios監控(一)

目 錄序言(必備知識)一、安裝規劃1.1系統環境1.2所需軟件包二、配置安裝環境2.1同步時間2.2禁用SElinux2.3 xftp上傳軟件包2.4安裝郵件服務三、監控主機安裝3.1安裝nagios的運行環境3.2增加用戶3.3安裝nagios3.4配置權限3.5安裝插件3.6安裝nrpe四、遠程主機安裝4.1配置運行環境…

java字符串刪掉子串_如何從Java中的列表中刪除子列表?

java字符串刪掉子串從列表中刪除子列表 (Removing SubList from a List) Suppose, we have a list of few elements like this, 假設我們列出了一些這樣的元素, list [10,20,30,40,50]From the list, we have to delete a sub list between sourcing_index (inclu…