tar command of linux (xzvf xjvf)

Reprinted from: http://blog.sina.com.cn/s/blog_62b250b50101og1l.html

tar [-cxtzjvfpPN] files and directories....

      parameter:
      -c : parameter command to create a compressed file (meaning of create);
      -x : Unpack the parameter command of a compressed file!
      -t : View the files in the tarfile!
      Special attention, in the parameter assignment, only one c/x/t can exist! cannot exist at the same time!
      Because it is impossible to compress and decompress at the same time.
      -z : Does it also have the gzip attribute? That is, does it need to be compressed with gzip?
      -j : Does it also have the properties of bzip2? That is, does it need to be compressed with bzip2?
      -v : Display files during compression! This is commonly used, but it is not recommended to be used in the background execution process!
      -f : Use the file name, please pay attention to the file name immediately after f! Do not add parameters!
 
x is decompression
c is compression 
z refers to gz files.
j refers to bz file
f specifies the file
 
================
 
Unzip: tar jxvf FileName.tar.bz2 
 
Compression: tar jcvf FileName.tar.bz2
 
z is used to decompress .tar.gz files, and .tar.bz2 files have to be replaced with j, like this: 
 
tar -xjvf linux-2.6.20.tar.bz2 
 
 
 
Take a look at the parameter description: 
 
x: decompress 
 
j:bz2 
 
f: specified file
 
 
TAR
command name
tar - The GNU version of the tar archive management program. The following will introduce their meanings one by one 
Overview
tar [ - ] A --catenate --concatenate | c --create | d --diff --compare | r --append | t --list | u --update | x -extract --get [ --atime-preserve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C, --directory DIR ] [ --checkpoint ]
[ -f, --file [HOSTNAME:]F ] [ --force-local ]
[ -F, --info-script F --new-volume-script F ] [ -G, --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [ -i, --ignore-zeros ] [ -I, --bzip ] [ --ignore-failed-read ] [ -k, --keep-old-files ] [ -K, --starting-file F ] [ -l, --one-file-system ] [ -L, --tape-length N ] [ -m, --modification-time ] [ -M, --multi-volume ] [ -N, --after-date DATE, --newer DATE ] [ -o, --old-archive, --portability ] [ -O, --to-stdout ] [ -p, --same-permissions, --preserve-permissions ] [ -P, --absolute-paths ] [ --preserve ]
[ -R, --record-number ] [ --remove-files ] [ -s, --same-order, --preserve-order ] [ --same-owner ] [ -S, --sparse ] [ -T, --files-from F ] [ --null ]
[ --totals ]
[ -v, --verbose ] [ -V, --label NAME ] [ --version ]
[ -w, --interactive, --confirmation ] [ -W, --verify ]
[ --exclude FILE ] [ -X, --exclude-from FILE ] [ -Z, --compress, --uncompress ] [ -z, --gzip, --ungzip ]
[ --use-compress-program PROG ] [ --block-compress ] [ -[0-7][lmh] ]
 
filename1 [ filename2, ... filenameN ]
directory1 [ directory2, ...directoryN ]
 
describe
The tar program is used to store or expand tar archive files. Archive files can be placed on disk or stored as regular files. tar requires parameters. The optional parameters are A, c, d, r, t, u, x. When using tar, you must first specify at least one parameter for tar; then, you must specify the file or directory to be processed . If a directory is specified, all subdirectories under that directory will be added to the archive. 
Application examples:
1) Expand abc.tar.gz Use the command: tar xvzf abc.tar.gz Expand abc.tar Use the command: tar xvf abc.tar
2) Save the man directory and its subdirectories in the current directory as an archive man.tar tar cf man.tar ./man 
Parameter Description
When running tar, you must have at least one of the following parameters to run
-A, --catenate, --concatenate
Merge an archive with an existing archive 
-c, --create 
create new archive
-d, --diff, --compare
Compare the difference between the archive and the current file 
--delete 
delete from archive
-r, --append 
Append to end of archive
-t, --list 
List directories of files in archive
-u, --update 
Append only newer files to the archive
-x, --extract, --get 
Expand file from archive
 
Other parameters
--atime-preserve 
Do not change the access time of the dump file
-b, --block-size N 
Specify a block size of Nx512 bytes (N=20 by default)
-B, --read-full-blocks 
Reassemble blocks on read (???!!!)
-C, --directory DIR
Go to the specified directory
--checkpoint 
Display directory name when reading archive
-f, --file [HOSTNAME:]F 
Specify archive or device (default is /dev/rmt0)
--force-local 
Force the use of a local archive, even if clones exist
-F, --info-script F --new-volume-script F
use script F at the end of each disk (implies -M)
-G, --incremental 
Make a backup of the old GNU format
-g, --listed-incremental F
Create a backup in the new GNU format
-h, --dereference 
Do not dump dynamic links, dump the files pointed to by dynamic links.
-i, --ignore-zeros 
Ignore 0-byte blocks in the archive (usually means end of file)
--ignore-failed-read 
Exit after marking 0 in unreadable file? ? ?
-k, --keep-old-files 
Save existing files; do not overwrite when expanding from archive
-K, --starting-file F 
Start with archive file F
-l, --one-file-system 
Create an archive in the local file system
-L, --tape-length N 
Pause after writing N*1024 bytes, waiting for disk replacement
-m, --modification-time 
When restoring files from an archive, do not use a new timestamp
-M, --multi-volume 
Create multi-volume archives for storage on several disks
-N, --after-date DATE, --newer DATE 
Store only newer files
-o, --old-archive, --portability 
Archive in V7 format, not ANSI format
-O, --to-stdout 
expand file to standard output
-p, --same-permissions, --preserve-permissions
Expand all protected information
-P, --absolute-paths 
Do not strip '/' from filenames
--preserve 
like -p -s
similar to -p -s
-R, --record-number 
Display the number of records in the archive at the same time
--remove-files 
Delete source files after creating archive
-s, --same-order, --preserve-order 
???
--same-owner
After expansion make all files belong to the same owner
-S, --sparse
Efficient processing
-T, --files-from F
get the name of the file to expand or create from the file
--null
Read null-terminated filenames, disable -C
--totals
Displays the total number of bytes written with the --create parameter
-v, --verbose
Detailed display of processed files
-V, --label NAME
Specify volume label for archive
--version
Display the version number of the tar program
-w, --interactive, --confirmation
Every operation requires confirmation
-W, --verify
Verify after writing to archive
--exclude FILE
Do not include the specified file
-X, --exclude-from FILE
Read in a list of files you don't want to include from the specified file
-y, --bzip2, --bunzip2
Compress or decompress archives with bzip2
-Z, --compress, --uncompress
compress or decompress archives with compress
-z, --gzip, --ungzip
Compress or decompress an archive with gzip
--use-compress-program PROG
Compress or decompress the archive with PROG (PROG needs to be able to accept the -d parameter)
--block-compress
Archive by block records for disk storage
-[0-7][lmh]
Specify drive and density [high-medium-low]
--------------------------
Packaging: tar -cf soft.tar soft
Unpack: tar -xf soft.tar soft
zip directory
Packaging and compression: tar czvf usr.tar.gz /home
Unzip: tar xzvf usr.tar.gz
Compressed files (for directory invalidation)
Compression: zip good.zip good1 good2
Unzip: unzip good.zip

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326642780&siteId=291194637