Linux压缩命令整理

[b]关于后缀名[/b]
[quote]*.Z compress程序压缩的文件
*.bz2 bzip2程序压缩的文件
*.gz gzip程序压缩的文件
*.tar tar程序打包的数据,没有经过压缩
*.tar.gz tar程序打包的数据,经过gzip压缩[/quote]

[b]1、compress[/b]
压缩
compress filename

解压缩
compress -d filename.Z

or
uncompress filename.Z


[b]2、bzip2,bzcat[/b]
[quote]bzip2 -h ──(Mon,Jul01)─┘
bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010.

usage: bzip2 [flags and input files in any order]

-h --help print this message
-d --decompress force decompression
-z --compress force compression
-k --keep keep (don't delete) input files
-f --force overwrite existing output files
-t --test test compressed file integrity
-c --stdout output to standard out
-q --quiet suppress noncritical error messages
-v --verbose be verbose (a 2nd -v gives more)
-L --license display software version & license
-V --version display software version & license
-s --small use less memory (at most 2500k)
-1 .. -9 set block size to 100k .. 900k
--fast alias for -1
--best alias for -9

If invoked as `bzip2', default action is to compress.
as `bunzip2', default action is to decompress.
as `bzcat', default action is to decompress to stdout.

If no file names are given, bzip2 compresses or decompresses
from standard input to standard output. You can combine
short flags, so `-v -4' means the same as -v4 or -4v, &c.[/quote]
bzip2 [-dz] filename

参数说明
-d :解压缩
-z :压缩
bzcat filename.bz2 读取压缩文件内容
同时bunzip2等同于bzip2 -d
[b]3、gzip,zcat[/b]
[quote]─ gzip -h ──(Mon,Jul01
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.

-c, --stdout write on standard output, keep original files unchanged
-d, --decompress decompress
-f, --force force overwrite of output file and compress links
-h, --help give this help
-l, --list list compressed file contents
-L, --license display software license
-n, --no-name do not save or restore the original name and time stamp
-N, --name save or restore the original name and time stamp
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories
-S, --suffix=SUF use suffix SUF on compressed files
-t, --test test compressed file integrity
-v, --verbose verbose mode
-V, --version display version number
-1, --fast compress faster
-9, --best compress better

With no FILE, or when FILE is -, read standard input.

Report bugs to <bug-gzip@gnu.org>.[/quote]
gzip [-d#] filename

zcat filename.gz
读取压缩文件的内容
参数说明:
-d : 解压缩的参数
-# : 压缩等级,1最不好,9最好,6为默认值

[b]4、tar[/b]
[quote]└─(22:30:%)── tar -h ──(Mon,Jul01)─┘
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
-c Create -r Add/Replace -t List -u Update -x Extract
Common Options:
-b # Use # 512-byte records per I/O block
-f <filename> Location of archive
-v Verbose
-w Interactive
Create: tar -c [options] [<file> | <dir> | @<archive> | -C <dir> ]
<file>, <dir> add these items to archive
-z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
--format {ustar|pax|cpio|shar} Select archive format
--exclude <pattern> Skip files that match pattern
-C <dir> Change to <dir> before processing remaining files
@<archive> Add entries from <archive> to output
List: tar -t [options] [<patterns>]
<patterns> If specified, list only entries that match
Extract: tar -x [options] [<patterns>]
<patterns> If specified, extract only entries that match
-k Keep (don't overwrite) existing files
-m Don't restore modification times
-O Write entries to stdout, don't restore to disk
-p Restore permissions (including ACLs, owner, file flags)
bsdtar 2.8.3 - libarchive 2.8.3[/quote]
tar [-zxcvfpP] filename
tar -N 'yyyy/mm/dd' /path -zcvf target.tar.gz source

参数说明:
-z:是否同时具有gzip
-x:解开一个压缩文件
-t:查看tarfile里面的文件
-c:建立一个压缩文件
-v:压缩过程中显示文件
-f:使用文件名字
-p:使用源文件的原文属性
-P:可以使用绝对路径
-N:比后面的接的日期还要新的文件才会被打包进新建的文件中
--exclude FILE:在压缩过程中,不要将FILE打包
e.g.

tar -cvf directory.tar directory
tar -zcvf directory.tar.gz directory
tar -xvf directory.tar #注意由于没有gzip的作用,所以只要使用-xvf即可,不需要加上z,否则会有问题
tar -zxvf directory.tar.gz #这时候就需要z了


参考资料:
鸟哥的Linux私房菜
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值