打印
[嵌入式linux]

Linux 归档压缩的问题

[复制链接]
1247|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
MCU2me|  楼主 | 2013-3-17 22:38 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
沙发
MCU2me|  楼主 | 2013-3-17 22:41 | 只看该作者

(53.97 KB )

使用特权

评论回复
板凳
原野之狼| | 2013-3-18 01:15 | 只看该作者
tar czvf xxx.tar.gz xxx
tar xzvf xxx.tar.gz

使用特权

评论回复
地板
MCU2me|  楼主 | 2013-3-18 08:54 | 只看该作者
原野之狼 发表于 2013-3-18 01:15
tar czvf xxx.tar.gz xxx
tar xzvf xxx.tar.gz

可是对于后缀是 tar.gz 的文件我直接用tar xvf 也能解压缩式为什么?不是应该加上 z 吗?见下图

QQ截图20130318085140.jpg (28.6 KB )

QQ截图20130318085140.jpg

使用特权

评论回复
5
原野之狼| | 2013-3-18 10:18 | 只看该作者
http://www.gnu.org/software/tar/ ... Formats.html#SEC132

8.1.1 Creating and Reading Compressed Archives

GNU tar is able to create and read compressed archives. It supports a wide variety of compression programs, namely: gzip, bzip2, lzip, lzma, lzop, xz and traditional compress. The latter is supported mostly for backward compatibility, and we recommend against using it, because it is by far less effective than the other compression programs(18).

Creating a compressed archive is simple: you just specify a compression option along with the usual archive creation commands. The compression option is ‘-z’ (‘--gzip’) to create a gzip compressed archive, ‘-j’ (‘--bzip2’) to create a bzip2 compressed archive, ‘--lzip’ to create an lzip compressed archive, ‘-J’ (‘--xz’) to create an XZ archive, ‘--lzma’ to create an LZMA compressed archive, ‘--lzop’ to create an LSOP archive, and ‘-Z’ (‘--compress’) to use compress program. For example:

       
$ tar cfz archive.tar.gz .
You can also let GNU tar select the compression program based on the suffix of the archive file name. This is done using ‘--auto-compress’ (‘-a’) command line option. For example, the following invocation will use bzip2 for compression:

       
$ tar cfa archive.tar.bz2 .
whereas the following one will use lzma:

       
$ tar cfa archive.tar.lzma .
For a complete list of file name suffixes recognized by GNU tar, see auto-compress.

Reading compressed archive is even simpler: you don't need to specify any additional options as GNU tar recognizes its format automatically. Thus, the following commands will list and extract the archive created in previous example:

       
# List the compressed archive
$ tar tf archive.tar.gz
# Extract the compressed archive
$ tar xf archive.tar.gz
The format recognition algorithm is based on signatures, a special byte sequences in the beginning of file, that are specific for certain compression formats. If this approach fails, tar falls back to using archive name suffix to determine its format (see auto-compress, for a list of recognized suffixes).

Some compression programs are able to handle different compression formats. GNU tar uses this, if the principal decompressor for the given format is not available. For example, if compress is not installed, tar will try to use gzip. As of version 1.26 the following alternatives are tried(19):

使用特权

评论回复
6
MCU2me|  楼主 | 2013-3-18 16:03 | 只看该作者
原野之狼 发表于 2013-3-18 10:18
http://www.gnu.org/software/tar/manual/html_chapter/Formats.html#SEC132

8.1.1 Creating and Reading  ...

红字下面几段 说的意思是tar命令先对特定的压缩文件识别 失败之后转而识别它的后缀 是这个意思吗?
可是这样的话 如果tar有自动识别并解压缩的能力 书中的例子tar xvf xxx.tar.gz 为什么会报错呢?

使用特权

评论回复
7
原野之狼| | 2013-3-18 19:28 | 只看该作者
1  给出操作指令序列

2  给出错误提示信息

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

11

主题

79

帖子

1

粉丝