O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compressing with lzma

lzma is comparatively new when compared to gzip or bzip2. lzma offers better compression rates than gzip or bzip2. As lzma is not preinstalled on most Linux distros, you may need to install it using the package manager.

How to do it...

In order to compress with lzma use the following command:

$ lzma filename
$ ls
filename.lzma

This will remove the file and produce a compressed file called filename.lzma.

To extract an lzma file use:

$ unlzma filename.lzma

This will remove filename.lzma and produce an uncompressed version of the file.

The lzma command can also read a file from stdin and write the compressed file to stdout.

In order to read from stdin and read out as stdout use:

$ cat file | lzma -c > file.lzma

-c is used to specify ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required