How uncompress tar.lz file

I was trying to uncompress a tar.lz file.

https://unix.stackexchange.com/questions/218230/why-i-cant-unpack-tar-bz2-or-tar-xz-files/218232#218232

Joses-MacBook-Air:~ joseluisbz$ ls -al /usr/local/Sources/ddrescue-1.22.tar.lz 
-rw-r--r--@ 1 joseluisbz  wheel  80050 Oct  4 14:43 /usr/local/Sources/ddrescue-1.22.tar.lz
Joses-MacBook-Air:~ joseluisbz$ tar zxvf /usr/local/Sources/ddrescue-1.22.tar.lz -C /usr/local/Sources/
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Joses-MacBook-Air:~ joseluisbz$ xz
xz: Compressed data cannot be written to a terminal
xz: Try `xz --help' for more information.
Joses-MacBook-Air:~ joseluisbz$ xz -dv /usr/local/Sources/ddrescue-1.22.tar.lz
/usr/local/Sources/ddrescue-1.22.tar.lz (1/1)
xz: /usr/local/Sources/ddrescue-1.22.tar.lz: File format not recognized
Joses-MacBook-Air:~ joseluisbz$ tar xjf /usr/local/Sources/ddrescue-1.22.tar.lz -C /usr/local/Sources/
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Joses-MacBook-Air:~ joseluisbz$ tar -xjf /usr/local/Sources/ddrescue-1.22.tar.lz -C /usr/local/Sources/
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Joses-MacBook-Air:~ joseluisbz$ tar -xjf /usr/local/Sources/ddrescue-1.22.tar.lz
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
Joses-MacBook-Air:~ joseluisbz$ 

What can I do?


Solution 1:

I use lzip, which I compiled from source code, however it can also be installed with Homebrew:

brew install lzip

See also: Lzip

You also need to have Command Line Tools for Xcode installed in either case. Have a look at: How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode)

$ lzip --help
Lzip - LZMA lossless data compressor.

Usage: lzip [options] [files]

Options:
  -h, --help                     display this help and exit
  -V, --version                  output version information and exit
  -a, --trailing-error           exit with error status if trailing data
  -b, --member-size=<bytes>      set member size limit in bytes
  -c, --stdout                   write to standard output, keep input files
  -d, --decompress               decompress
  -f, --force                    overwrite existing output files
  -F, --recompress               force re-compression of compressed files
  -k, --keep                     keep (don't delete) input files
  -l, --list                     print (un)compressed file sizes
  -m, --match-length=<bytes>     set match length limit in bytes [36]
  -o, --output=<file>            if reading standard input, write to <file>
  -q, --quiet                    suppress all messages
  -s, --dictionary-size=<bytes>  set dictionary size limit in bytes [8 MiB]
  -S, --volume-size=<bytes>      set volume size limit in bytes
  -t, --test                     test compressed file integrity
  -v, --verbose                  be verbose (a 2nd -v gives more)
  -0 .. -9                       set compression level [default 6]
      --fast                     alias for -0
      --best                     alias for -9
If no file names are given, or if a file is '-', lzip compresses or
decompresses from standard input to standard output.
Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,
Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...
Dictionary sizes 12 to 29 are interpreted as powers of two, meaning 2^12
to 2^29 bytes.

The bidimensional parameter space of LZMA can't be mapped to a linear
scale optimal for all files. If your files are large, very repetitive,
etc, you may need to use the --dictionary-size and --match-length
options directly to achieve optimal performance.

Exit status: 0 for a normal exit, 1 for environmental problems (file
not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or
invalid input file, 3 for an internal consistency error (eg, bug) which
caused lzip to panic.

Report bugs to [email protected]
Lzip home page: http://www.nongnu.org/lzip/lzip.html
$

Solution 2:

There's no need to install new software! At least on MacOS 10.15 tar has the option --lzip that decompresses .lz files. For instance:

tar --lzip -tf gmp-6.2.0.tar.lz

gives me

gmp-6.2.0/
gmp-6.2.0/cxx/
gmp-6.2.0/mini-gmp/
gmp-6.2.0/Makefile.am
gmp-6.2.0/configure
...

Solution 3:

I'm agree with @John Perry no need to install. Tested on my mac Mac OS Catalina (10.15.7)

To see contents of yourfile.tar.lz file tar --lzip -tf yourfile.tar.lz

To extract contents of yourfile.tar.lz tar --lzip -xvf yourfile.tar.lz