1. 编译 tarlz 的脚本
workdir=$(cd $(dirname ${0}) ; pwd)
yum install -y wget
wget http://download.savannah.gnu.org/releases/lzip/lzlib/lzlib-1.13.tar.gz
wget http://download.savannah.gnu.org/releases/lzip/tarlz/tarlz-0.23.tar.lz
yum install -y gcc-c++
# 编译 lzlib
cd ${workdir}
tar xzf lzlib-1.13.tar.gz && cd lzlib-1.13 && ./configure && make
# 编译 tarlz
cd ${workdir}
./lzlib-1.13/minilzip -d tarlz-0.23.tar.lz && tar xf tarlz-0.23.tar
cd tarlz-0.23 && ./configure CXXFLAGS+="-I ../lzlib-1.13" LDFLAGS="-L ../lzlib-1.13" && make
脚本执行完成后,则会在 tarlz-0.23 目录中生成 tarlz
文件。
2. tarlz 的使用方法
例如把目录 trand 打包并且压缩的命令如下
tarlz -c -9 -f trand.tar.lz trand/
对于文本文件,压缩率可以到 3%
左右。
tarlz 命令的 help 信息
Usage: ./tarlz operation [options] [files]
Operations:
--help display this help and exit
-V, --version output version information and exit
-A, --concatenate append archives to the end of an archive
-c, --create create a new archive
-d, --diff find differences between archive and file system
--delete delete files/directories from an archive
-r, --append append files to the end of an archive
-t, --list list the contents of an archive
-x, --extract extract files/directories from an archive
-z, --compress compress existing POSIX tar archives
--check-lib check version of lzlib and exit
Options:
-B, --data-size=<bytes> set target size of input data blocks [2x8=16 MiB]
-C, --directory=<dir> change to directory <dir>
-f, --file=<archive> use archive file <archive>
-h, --dereference follow symlinks; archive the files they point to
-n, --threads=<n> set number of (de)compression threads [40]
-o, --output=<file> compress to <file>
-p, --preserve-permissions don't subtract the umask on extraction
-q, --quiet suppress all messages
-v, --verbose verbosely list files processed
-0 .. -9 set compression level [default 6]
--uncompressed don't compress the archive created
--asolid create solidly compressed appendable archive
--bsolid create per block compressed archive (default)
--dsolid create per directory compressed archive
--no-solid create per file compressed archive
--solid create solidly compressed archive
--anonymous equivalent to '--owner=root --group=root'
--owner=<owner> use <owner> name/ID for files added to archive
--group=<group> use <group> name/ID for files added to archive
--exclude=<pattern> exclude files matching a shell pattern
--ignore-ids ignore differences in owner and group IDs
--ignore-overflow ignore mtime overflow differences on 32-bit
--keep-damaged don't delete partially extracted files
--missing-crc exit with error status if missing extended CRC
--mtime=<date> use <date> as mtime for files added to archive
--out-slots=<n> number of 1 MiB output packets buffered [64]
--warn-newer warn if any file is newer than the archive