The tar command can be used to package and unpack. Packaging refers to a large number of files or directories into a total file, compression is a large file through some compression algorithm into a small file. So package unpacking and compression decompression is not the same, compression and decompression commonly used commands have gzip and bzip2 and so on.
Command 1 packaging commands, the-c parameter indicates a new compressed file,-V for the display process, and-F for the specified compressed file. -Z to support gzip decompression files,-j means just bzip2 extract files.
TAR-CVF Log.tar Log2012.log
The file name after the parameter F is taken by itself, and we are accustomed to using. Tar as an identification. If the z parameter is added, a. tar.gz or. tgz is used to represent the gzip compressed tar package, or the. tar.bz2 as the TAR package name if the J parameter is added.
Command 2 after packaging with GIZP compression
TAR-ZCVF log.tar.gz Log2012.log
Command 3 View a compressed file,-T indicates that a file under a compressed package is displayed
TAR-ZTVF log.tar.gz
Command 4 unzip a compressed file,-X indicates the extracted file
TAR-ZXVF log.tar.gz
Command 5 packages new files more than a certain time
Tar-n "2012/11/13"-ZCVF log17.tar.gz test
Command 6 exclude certain files from packaging
Tar--exclude scf/service-zcvf scf.tar.gz scf/*
The commonly used decompression and compression commands are:
Tar unpacking: Tar xvf filename.tar pack: Tar cvf filename.tar DirName (Note: Tar is packaged, not compressed!) ). GZ decompression 1:gunzip filename.gz decompression 2:gzip-d filename.gz compression: gzip FileName.tar.gz and. tgz decompression: Tar zxvf FileName.tar.gz compression: Tar ZCVF FileName.tar.gz dirname.bz2 Decompression 1:bzip2-d filename.bz2 decompression 2:bunzip2 filename.bz2 compression: bzip2-z FileName.tar.bz2 decompression: Tar jxvf FILENAME.TAR.BZ2 compression: Tar jcvf FileName.tar.bz2 dirname.bz decompression 1:bzip2-d filename.bz extract 2:BUNZIP2 FILENAME.BZ compression: Unknown. Tar.bz decompression: Tar jxvf FileName.tar.bz compression: unknown. Z Decompression: uncompress filename.z compression: Compress filename.tar.z Decompression: tar ZXVF filename.tar.z compression: Tar zcvf filename.tar.z dirname.zip decompression: Unzip Filename.zip compression: Zip filename.zip Dirname.rar extract: rar x Filename.rar compression: rar a Filename.rar DirName
Reference Document: Http://www.cnblogs.com/peida/archive/2012/11/30/2795656.html
Linux Command-tar command