Ubuntu--tar Instruction Detailed (reprint)

Source: Internet
Author: User
Tags bz2 gz file unpack

Original
tar zxvf ut6410-android2.1.tgz

tar zcvf ut6410-android2.1.tgz ut6410-android2.1/tar--exclude ut6410-android2.1/out-zcvf ut6410-android2.1.tgz ut6410-android2.1/

  tar command
[[Email protected] ~]# tar [-cxtzjvfppn] files and directories ....
Parameters:
-C: Create a compressed file parameter directive (the meaning of Create);
-x: Unlock the parameter instructions for a compressed file!
-T: View the files inside the Tarfile!

In particular, in the release of the parameters, c/x/t can only exist one! Cannot exist at the same time!
Because it is not possible to compress and decompress simultaneously.
-Z: Do you have the properties of gzip at the same time? i.e. do I need gzip compression?
-j: Do you have bzip2 properties at the same time? i.e. is it necessary to compress with bzip2?
-V: Files are displayed during compression! This is commonly used, but is not recommended for use in the background execution process!
-F: Use the file name, please note, after F to immediately answer the file name Oh! Don't add any more arguments!
For example, using "TAR-ZCVFP tfile sfile" is the wrong way to write
"TAR-ZCVPF tfile sfile" Just right!
-P: Use original file properties (attributes are not changed according to user)
-P: You can use absolute path to compress!
-N: Newer than next date (YYYY/MM/DD) will be packaged in the new file!
--exclude file: In the process of compression, do not package file!
Example tar:
Example one: Package all the files in the/etc directory into/tmp/etc.tar
[[email protected] ~]# TAR-CVF/TMP/ETC.TAR/ETC <== package only, do not compress!
[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, compressed with gziptar zcvf ut6410.tgz ut6410/
[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== packaged, bzip2 compressed
# Note that the file name after parameter f is taken by yourself, and we are accustomed to using. Tar as a recognition.
# if the z parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~
# If you add the J parameter, use. tar.bz2 as the file name.
# When the above instruction is executed, a warning message is displayed:
# "tar:removing leading '/' from member names" That's a special setting for absolute paths.
Tar example two: check what files are in the/tmp/etc.tar.gz file above?
[Email protected] ~]# tar-ztvf/tmp/etc.tar.gz
# because we use gzip compression, so to check the file in the tar file,
# you have to add Z to this parameter! It's important!
Tar Example three: Extract the/tmp/etc.tar.gz file under/USR/LOCAL/SRC
[Email protected] ~]# CD/USR/LOCAL/SRC
[Email protected] src]# tar-zxvf/tmp/etc.tar.gz
# in the case of presets, we can unzip the file anywhere! In the case of this example,
# I'm going to transform my working directory under/USR/LOCAL/SRC and untie/tmp/etc.tar.gz,
# then the unpacked catalogue will be in/USR/LOCAL/SRC/ETC! Also, if you enter/USR/LOCAL/SRC/ETC
# you will find that the file attributes in this directory may be different from the/etc/.
Tar example four: under/tmp, I just want to untie the etc/passwd in/tmp/etc.tar.gz.
[Email protected] ~]# cd/tmp
[Email protected] tmp]# tar-zxvf/tmp/etc.tar.gz etc/passwd
# I can check the file name in the Tarfile through TAR-ZTVF, if only one file,
# can be released in this way! Notice that! The root directory within the etc.tar.gz/is taken away!
Tar example five: Back up all the files in the/etc/and save their permissions!
[Email protected] ~]# tar-zxvpf/tmp/etc.tar.gz/etc
# The properties of this-p are important, especially if you want to keep the properties of the original file!
Example tar six: In/home, newer than 2005/06/01 files are backed up
[Email protected] ~]# tar-n ' 2005/06/01 '-ZCVF home.tar.gz/home
Tar example seven: I want to back up/home, etc, but don't/home/dmtsai
[Email protected] ~]# tar--EXCLUDE/HOME/DMTSAI-ZCVF myfile.tar.gz/home/*/etc
Tar example eight: unpack the/etc/directly under/TMP without generating files!
[Email protected] ~]# cd/tmp
[Email protected] tmp]# TAR-CVF-etc | TAR-XVF-
# This action is a bit like cp-r tar--exclude/data/web/aaa--exclude/data/web/bbb-cvzf data.tar.gz/data/web/etc/tmp ~ still has its useful The way!
Note that the output file becomes-and the input file becomes-and another | exist ~
# This represents the standard output, the standard input and the pipeline command!

Tar instance eight: File mm.c, folder mm\mm.c not packaged in --exclude the corresponding folder after it does not have/

[[email protected]] #tar--exclude/ut/mm.c--EXCLUDE/UT/MM-ZCVF ut.tgz ut

Packaged out ut.tgz, not including MM.C and MM folders
Article from: Lao Li's Diary. SOURCE address: Http://www.dayanmei.com/blog.php/ID_1009.htmtar on Linux is a common packaging, compression, compression tools, he has a lot of parameters, folding only to enumerate the commonly used compression and decompression parameters

Parameters:

-c:create set up the parameters of compressed archives;

-X: Extracting parameters of compressed archives;

-Z: Whether to use gzip compression;

-V: Files are displayed during compression;

-F: The top document name, immediately after F to answer the file name, can not add parameters

-U: Update files in original compressed package
These six are stand-alone commands, which use one of the compression decompression, and can be used with other commands but only one. The following parameters are optional when compressing or extracting files as needed.
-Z: With gzip properties
-j: With the bz2 attribute
-Z: With the Compress attribute
-V: Show All procedures
-O: Unpack the file to standard output

The following parameter-F is required
-F: Use the file name, remember that this parameter is the last parameter, can only be followed by the file name.
# TAR-CF All.tar *.jpg
This command is to make all. jpg files into a package named All.tar. -C is the file name that represents the generation of a new package,-f specifies the package.
# TAR-RF All.tar *.gif
This command adds all the. gif files to the All.tar package. -R is meant to increase the file.
# Tar-uf All.tar logo.gif
This command is to update the original tar package All.tar in the logo.gif file,-U is to indicate the meaning of the update file.
# TAR-TF All.tar
This command is to list all the files in the All.tar package,-T is to list the meaning of the file
# TAR-XF All.tar
This command is to solve all the files in the All.tar package,-T is to untie the meaning


Compression
TAR–CVF Jpg.tar *.jpg//package all JPG files in the directory into tar.jpg

TAR–CZF jpg.tar.gz *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in gzip to generate a gzip compressed package named jpg.tar.gz

TAR–CJF jpg.tar.bz2 *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in bzip2 to generate a bzip2 compressed package named jpg.tar.bz2

TAR–CZF jpg.tar.z *.jpg//pack all JPG files in the directory into Jpg.tar and compress them in compress to generate a umcompress compressed package named Jpg.tar.z

RAR a jpg.rar *.jpg//rar format compression, you need to download RAR for Linux first

Zip jpg.zip *.jpg//zip format compression, need to download zip for Linux First



Extract
TAR–XVF File.tar//Unpacking the TAR Package

TAR-XZVF file.tar.gz//Decompression tar.gz

TAR-XJVF file.tar.bz2//Decompression tar.bz2

TAR–XZVF file.tar.z//Unzip tar. Z

Unrar e file.rar//decompression rar

Unzip File.zip//Unzip zip


Summarize
1, *.tar with TAR–XVF decompression

2, *.gz with gzip-d or gunzip decompression

3, *.tar.gz and *.tgz with TAR–XZF decompression

4, *.bz2 with bzip2-d or with BUNZIP2 decompression

5, *.tar.bz2 with TAR–XJF decompression

6, *. Z Extract with Uncompress

7, *.tar. Z Extract with Tar–xzf

8, *.rar with Unrar e decompression

9, *.zip with unzip decompression

Example: First, the entire/home/www/images directory of files are packaged as/home/www/images.tar

[[email protected] ~]# tar-cvf/home/www/images.tar/home/www/images← package only, do not compress

[[email protected] ~]# tar-zcvf/home/www/images.tar.gz/home/www/images← after packing, compress with gzip

The compressed file name after the parameter F is self-fetching, used in tar to do, if the z parameter, then tar.gz or tgz to represent the gzip compressed tar file file

Example: Two, extract/home/www/images.tar.gz to/home/www below

[Email protected] ~]# cd/home/www

[Email protected] ~]# tar-zxvf/home/images.tar.gz

Unzip to the specified directory

[Email protected] ~]# tar-zxvf/home/images.tar.gz-c/specific dir

Unpacking to the specified directory

Tar xvf filename.tar-c/specific dir

Ubuntu--tar Instruction Detailed (reprint)

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.