Concise Linux Command Line notes: Tar

Source: Internet
Author: User
Tags gz file
ArticleDirectory
    •  
    • Parameters
    • Option
    • Modifier
    • Example
    • Tips

Store the file to an archive file or obtain the original file from the archive file, and create an archive file for the file

Tar [Option] [Modifiers] [File-list]

Parameters

File-listYesTarList of file path names for archiving and Extraction

 

Option

You can only use one of the following options to specify the actions to be executed by tar. You can change the behavior of an option by following one or more modifiers.

-C. Create an archive file

-U: add files in file-list to archive files.

-X extracts file-list from the archive file and writes it to the disk.

 

Modifier

-C dir: Switch the working directory to the directory specified by Dir before processing.

-F filename uses filename to specify the file name of the archive file to be created or extracted from

-J. Use Bzip2 for compression and decompression when creating an archive file or extracting a file from the archive file

-When creating an archive file or extracting a file from the archive file, use gzip to compress and decompress the file.

-V: list every file read or written by tar.

-T list the directories in the archive file

-U: update an archive file

 

Example Tar-CVF
 
Siu @ darling ~ /Work $Tar-CVF demo.TarA B cabcsiu @ darling~ /Work $LsA B C demo.TarDir

Pack a B c into an archive file named demo.tar and display the packaged File

Extension name tar is used to identify the file type

 

Tar-xvf
Siu @ darling ~ /Work $LsDemo.TarDirSiu @ darling~ /Work $Tar-Xvf demo.TarAbcsiu @ darling~ /Work $LsA B C demo.TarDir

Decompress the archive file named demo.tar to the local directory and display the decompressed file.

 

Tar-zcvf
Siu @ darling ~ /Work $Tar-Zcvf demo.Tar. Gz a B cabcsiu @ darling~ /Work $LsA B C demo.TarDemo.Tar. GZDir

Pack and compress the three files a B and C in the gzipformat to demo.tar.gz.

 

Tar-zxvf
 
Siu @ darling ~ /Work $Tar-Zxvf demo.Tar. Gzabcsiu @ darling~ /Work $LsA B C demo.TarDemo.Tar. GZDir

Decompress the demo.tar.gz file using the gunzip' Formula

 

Tar-jcvf
 
Siu @ darling ~ /Work $Tar-Jcvf demo.Tar. Bz2 a B cabcsiu @ darling~ /Work $LsA B C demo.TarDemo.Tar. Bz2 demo.Tar. GZDir

Compress the three files a B and C with bzip2and package them to demo.tar.bz2.

  Tar-jxvf
Siu @ darling ~ /Work $LsDemo.TarDemo.Tar. Bz2 demo.Tar. GZDirSiu @ darling~ /Work $Tar-Jxvf demo.Tar. Bz2 abcsiu @ darling~ /Work $LsA B C demo.TarDemo.Tar. Bz2 demo.Tar. GZDir

Decompress demo.tar.bz2 to the current directory using bunzip2.

 

Tar-jxvf-C
Siu @ darling ~ /Work $Tar-Jxvf demo.Tar. Bz2-C ./DirAbcsiu @ darling~ /Work $LsDemo.Tar. Bz2DirSiu @ darling~ /Work $Ls DirA B CSIU @ darling~ /Work $

Decompress the archive file to the specified directory

 

Tips

1.tar is only used for packaging, but not compressed. Bzip2 and gzip can only be used to compress a single file, but cannot be compressed.

2. Tar-jcvf and tar-zcvf solve the above problems

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.