Linux in file packaging and compression

Source: Internet
Author: User
Tags bz2 gz file

1. Packaging and compressing files
Linux now often uses gzip and bzip2 files to compress. Tar compressed files.

Frequently used extensions: *.gz gzip Compressed files *.bz2 bzip2 Compressed files *.tar tar packaged files, no compressed *.tar.gz tar package files. Gzip Compressed *.tar.bz2 tar package files, bzip2 compressed
2. Gzip compression
Gzip is the most widely used compression command. Used to replace compress compression.

$ gzip-hgzip 1.3.3 (2002-03-08) usage:gzip [-cdfhllnnrtvv19] [-s suffix] [file ...] Frequently used Parameters-C: Compressed data output to the screen, can redirect processing-D: Decompression-T: Verify the consistency of the compressed file. See if the file is error-V: Displays specific information about the compression. Compression ratio, etc.-#: number, compression level, 1-9,9 compression rate, default 6
Compress files
$ gzip-v testtest:   53.1%--Replaced with test.gz
Compression will erase the local file. New test.gz file does not delete files using redirection
$ gzip-c Test > test.gz
View the contents of the compressed file, without unzipping the case. Using the Zcat command

3. bzip2
BZIP2 is used to replace gzip compression, which is higher than the gzip compression ratio. The use of the parameters is almost the same as gzip.
$ BZIP2-HBZIP2, a block-sorting file compressor.  Version 1.0.2, 30-dec-2001.   USAGE:BZIP2 [flags and input files in any order] frequently use the parameter-C: Compress the data output to the screen. Redirect-D: Unzip-K: Keep the original file-Z: Compress-T: Verify the consistency of the compressed file. See if the file is error-V: Displays specific information about the compression. Compression ratio, etc.-#: number, compression level. 1-9,9 compression rate is highest. Default 6
Use
#压缩test文件, generate test.bz2$ bzip2-z test# retain original file, compress generate test.bz2$ bzip2-k test# extract file $ bzip2-d test.bz2
View compressed file contents, using Bzcat

3. Packaging: Tar
Tar is a packaged command. Package multiple files into one file. Also includes compression parameters.

$ tar--helpgnu ' tar ' saves many files together into a single tape or disk archive, Andcan restore individual files from T He archive. Usage:tar [OPTION] ... [FILE] ... Examples:  tar-cf archive.tar foo bar  # Create Archive.tar from Files foo and bar.  TAR-TVF Archive.tar         # List All files in Archive.tar verbosely.  TAR-XF Archive.tar          # Extract all files from Archive.tar. #參数-C New Compressed file-T list compressed file list-X Extract file   -c,-t,-x cannot appear at the same time-j by Bzi P2 to compress or decompress. The file name is best for. *.tar.bz2-z by gzip compression or decompression, the file name is best for *.TAR.GZ-V show the specific information being processed-F after the file name to be processed-C decompression, followed by the extracted folder name-p to retain the original permissions of the file-P Keep absolute path--exclude=file exclude file files
Basic methods of using tar
#创建bzip2压缩文件 $ tar-jcv-f test.tar.bz2 test/test/test/1test/10# Create gzip compressed file $ tar-zcv-f test.tar.gz testtest/test/1test/ 10# View Files $ lldrwxrwxr-x  2 work work     4096 Jul 19:12 test-rw-rw-r--1 Work work    61897 Jul 19:13 Test.tar . bz2# View File List $ tar-jtv-f test.tar.bz2 tar:record size = 8 blocksdrwxrwxr-x work/work         0 2014-07-19 19:12:40 tes t/-rw-rw-r--work/work      6353 2014-07-19 19:12:40 test/1-rw-rw-r--work/work      6343 2014-07-19 19:12:40 test/10# Unzip to current folder $ tar-jxv-f test.tar.bz2 test/test/1test/10# extract to the specified folder test2$ mkdir test2$ tar-jxv-f test.tar.bz2-c test2  
Do not include a file when packaging
#创建压缩文件, excluding a file test/10$ tar-zcv-f test.tar.gz  --EXCLUDE=TEST/10 TEST/*TEST/1
Back up files that are newer than at some point
$ tar-zcv-f etc.tar.gz--newer-mtime= "2013/10/31"/etc/*/etc/xinetd.d/tar:/etc/yp.conf:file is unchanged; Not Dumped#not DUMPD indicates that there is no backup

Address: http://blog.csdn.net/yonggang7/article/details/37963793

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Linux in file packaging and compression

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.