linux--and the original--tar command

Source: Internet
Author: User
Tags bz2

Compression and decompression

Tar command

The tar command can be used to create files and archives for Linux.

With tar, you can create files for a specific file (a file), change files in a file, or add new files to the file. Tar was originally used to create files on a magnetic tape, and now, you can create files on any of your facilities.

With the tar command, you can package a whole bunch of files and records into a single file, which is very useful for preparing files or combining several files into a file for network transport.

The first thing to understand is two concepts: packaging and compression.

Packaging refers to a large number of files or records into a large file; The compression method transforms a large file through some compression algorithms into a small file.

Why do you want to divide these two concepts? This is because many of the compression programs in Linux can only compress a single file, so when you want to compress a lot of files, you have to first make a bundle of these files (the tar command) and then use the compression program to compress (gzip bzip2 commands).

Language structures

Tar (option) (The new file needs to be packaged)

Option

1 2 3 4 5 6 7 8 9-All of the following: Add a file to the existing file;-B: Set the size of the block;-C or--create: Create a new copy of the file -c<;: This option is used for decompression, which is the option to use in order to decompress in a specific recording. -D: The difference between the records;-X or--extract or--get: The original file from the prepared document;-T or--list: Lists the contents of the file,-Z or--gzip, or--ungzip: through the gzip command to process the files; Z or--compress or--uncompress: Through the Compress instructions for the preparation of documents,-f< prepare documents > or--file=< files;: Specify the files;-V or--verbose: Show instructions to perform the process; R: Add files to an already compressed file;-U: Add changes and existing files to existing compression files;-j: supports bzip2 files;-V: Shows the operation process;-L: File system border setting;-K: Retain the original file without overwriting;-W: Keep the file not covered; The accuracy of the file,-P or--same-permissions: The original file is the same as the original file;-P or--absolute-names: The filename uses the absolute name, does not remove the "/" symbol before the filename,-n< date format > or--newer= < date;: Save only files that are updated on the specified date to the file;--exclude=< template;: Exclude files that conform to the template.

Parameters

File or Catalog: Specify the file or list to be packaged

Example: Spare parts

Package all files into a tar package

1 2 3 TAR-CVF Log.tar Log2017.log #僅打包, non-compression. TAR-ZCVF log.tar.gz log2017.log #打包後, gzip tar-jcvf log.tar.bz2 log2017.log #打包後 to bzip2 compression

The file name after the option F is taken, and we are used to it. Tar. If you add the z option, the. tar.gz or. tgz represent the gzip-compressed tar package, and if you add J, the. tar.bz2 is used as the TAR package name.

Check out those files in the tar package.

1 2 3 TAR-TVF Log.tar #查看tar包內的文件, two types of compression packs can be viewed. TAR-ZTVF log.tar.gz #查看tar包內的文件, in gzip-compressed format package. TAR-JTVF log.tar.bz2 #查看tar包內的文件, packages in bzip2 compression format.

File, and save its rights:

1 TAR-ZCVPF log31.tar.gz Log2014.log log2015.log log2016.log More professional Related: http://www.unixlinux.online/unixlinux/ Linuxjcgylinux/201704/103965.html

linux--and the original--tar command

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.