QQ网名大全

为什么linux中 tar打包后的文件比原来大?

tar本身只是一个打包工具,把多个文件或目录打包成一个文件,方便保存和传输。打包后的文件有一些额外信息,导致文件变大。但是tar也提供了一些参数,在打包的过程中进行压缩,这样得到的文件就会比较小;相应的,解包的时候也要有对应的参数进行解压。

tar --help
.......
Compression options:

-a, --auto-compress use archive suffix to determine the compression
program
-I, --use-compress-program=PROG
filter through PROG (must accept -d)
-j, --bzip2 filter the archive through bzip2
-J, --xz filter the archive through xz
--lzip filter the archive through lzip
--lzma filter the archive through xz
--lzop
--no-auto-compress do not use archive suffix to determine the
compression program
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
-Z, --compress, --uncompress filter the archive through compress
......

例如下面的例子,使用gzip进行压缩和解压:
tar -czf file.tar.gz ./file

tar -zxf file.tar.gz
希望能解决您的问题。
佚名
2024-05-30 19:58:40
最佳回答
类似问题(10)