Ubuntu -- tar command 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] file and directory ....
Parameters:
-C: Create a parameter command for the compressed file );
-X: Unlock the parameter command of a compressed file!
-T: view the files in the tarfile!
Note that C/X/T can only exist under the parameter! Cannot exist at the same time!
Because it is impossible to simultaneously compress and decompress.
-Z: does it have the gzip attribute at the same time? That is, do I need to use gzip for compression?
-J: Does it have Bzip2 attributes at the same time? That is, do I need to use Bzip2 for compression?
-V: The file is displayed during compression! This is common, but it is not recommended to use it in the background execution process!
-F: use the file name. Please note that the file name should be followed immediately after F! Do not add parameters!
For example, using "Tar-zcvfp tfile sfile" is an incorrect method.
"Tar-zcvpf tfile sfile" is correct!
-P: use the original attributes of the original file (the attributes will not be changed based on the user)
-P: absolute paths can be used for compression!
-N: a new date (yyyy/mm/DD) will be packed into the new file!
-- Exclude file: do not pack the file during compression!
Tar example:
Example 1: 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 <= compressed by gzip tar zcvf ut6410.tgz ut6410/
[[Email protected] ~] # Tar-jcvf/tmp/etc.tar.bz2/etc <= compressed with Bzip2
# Note that the file name after parameter F is obtained by ourselves. We use. tar for identification.
# If the Z parameter is added, .tar.gz or. tgz is used to represent the tar file ~ compressed by gzip ~
# If you add the J parameter, use .tar.bz2 as the file name ~
# A warning message is displayed when the preceding command is executed:
# "Tar: removing leading '/' from Member names" is a special setting for absolute paths.
Tar Example 2: Check the files in the above/tmp/etc.tar.gz file?
[[Email protected] ~] # Tar-ztvf/tmp/etc.tar.gz
# When we use gzip to compress the files in the TAR file,
# Add the Z parameter! This is important!
Tar Example 3: Decompress 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
# By default, We Can uncompress files anywhere! In this example,
# First, I will transform the working directory to the/usr/local/src directory, and unlock/tmp/etc.tar.gz,
# The unlocked directory will be in/usr/local/src/etc! In addition, if you enter/usr/local/src/etc
# The file attributes in this directory may be different from those in/etc!
Tar Example 4: Under/tmp, I only want to unbind 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 use tar-ztvf to check the file name in the tarfile. If you only need one file,
# You can issue it in this way! Notice! The root directory in etc.tar.gz/is removed!
Tar Example 5: Back up all files in/etc/and save the permission!
[[Email protected] ~] # Tar-zxvpf/tmp/etc.tar.gz/etc
# This-P attribute is very important, especially when you want to keep the attributes of the original file!
Tar Example 6: In/home, a new file is backed up only after 2005/06/01.
[[Email protected] ~] # Tar-N '2014/1/01'-zcvf home.tar.gz/home
Tar Example 7: I want to back up/home,/etc, but do not/home/dmtsai
[[Email protected] ~] # Tar -- exclude/home/dmtsai-zcvf myfile.tar.gz/home/*/etc
Tar Example 8: package/etc/and unpack it under/tmp without generating a file!
[[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 ~ It is still useful!
# Note that the output file is changed to-and the input file is changed to-, and there is another file | Yes ~
# This represents standard output, standard input, and pipeline commands respectively!
Tar instance 8: Do not package the file mm. C and the folder mm \ mm. C. do not include/in the corresponding folder after exclude/
[[Email protected] # tar -- exclude/UT/mm. c -- exclude/UT/MM-zcvf ut. tgz UT
The ut. tgz package does not contain the MM. C and mm folders.
Article from: Lao Li's log. Source Address: bytes
Parameters:
-C: Create parameters for creating compressed files;
-X: extract the compressed file parameters;
-Z: whether gzip compression is required;
-V: displays files during compression;
-F: Specifies the document name. The file name is immediately followed by F. No parameter can be added.
-U: update files in the original compressed package
These six are independent commands, and one of them is required for compression and decompression. They can be used with other commands, but only one of them can be used. The following parameters are optional when files are compressed or decompressed as needed.
-Z: With the gzip attribute
-J: With the bz2 attribute
-Z: With the compress attribute
-V: displays all processes.
-O: unbind the file to the standard output
The following parameter-F is required
-F: use the file name. Remember, this parameter is the last parameter and can only be followed by the file name.
# Tar-CF all.tar *. jpg
This command is to pack all. jpg files into a package named all.tar. -C indicates that a new package is generated.-F specifies the package file name.
# Tar-RF all.tar *. gif
This command adds all .gif files to the package of all.tar. -R indicates adding files.
# Tar-UF all.tar logo.gif
This command is used to update the logo.gif file in tarbao all.tar.-u indicates that the file is updated.
# Tar-TF all.tar
This command is used to list all files in the all.tar package.-T is used to list objects.
# Tar-XF all.tar
This command is used to extract all the files in the all.tar package.
Compression
Tar-CVF jpg.tar *. jpg // pack all JPG files in the Directory into tar.jpg
Tar-CZF jpg.tar.gz *. jpg // JPG
Tar-CJF jpg.tar.bz2 *. jpg // JPG
Tar-CZF jpg.tar. z *. jpg // JPG. Z
Rar a jpg.rar *. jpg // RAR format compression, You need to download RAR for Linux
Zip jpg.zip *. jpg // ZIP format compression, You need to download zip for Linux first
Extract
Tar-xvf file.tar // decompress the tar package
Tar-xzvf file.tar.gz // decompress tar.gz
Tar-xjvf file.tar.bz2 // unzip tar.bz2
Tar-xzvf file.tar. Z // extract tar. Z
Unrar e file.rar // extract RAR
Unzip file.zip // decompress the ZIP file
Summary
1. Decompress *. tar with tar-xvf
2. Use gzip-D or gunzip to decompress *. GZ
3. Use tar-xzf to decompress * .tar.gz and *. tgz.
4. Use Bzip2-D for *. bz2 or use bunzip2 for decompression.
5. Use tar-xjf to decompress * .tar.bz2
6. Use uncompress to decompress *. Z
7. Decompress *. Tar. Z with tar-xzf
8. Extract files using unrar E for *. rar
9. Decompress *. Zip with unzip
Example: 1. Package all the files in the/home/www/images directory as/home/www/images.tar.
[[Email protected] ~] # Tar-CVF/home/www/images.tar/home/www/images packages are only packaged and not compressed
[[Email protected] ~] # Tar-zcvf/home/www/images.tar.gz/home/www/images compressed with Gzip
The name of the compressed file after the fzip file is obtained by using the tar.gz or tgz.
Example 2: extract/home/www/images.tar.gz to/home/WWW
[[Email protected] ~] # Cd/home/WWW
[[Email protected] ~] # Tar-zxvf/home/images.tar.gz
Decompress the package to the specified directory.
[[Email protected] ~] # Tar-zxvf/home/images.tar.gz-C/specific dir
Unpackage to the specified directory
Tar xvf filename.tar-C/specific dir