Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
lha(1)			     General Commands Manual			  lha(1)

NAME
     lha - compression tool for .lzh archive files.

SYNOPSIS
     lha [-]{lvtxep[q{num}][finv]}[w=<dir>] archive_file [file ...]

DESCRIPTION
     lha  is a tool for extracting .lzh archive files. It also supports variants
     of the .lzh archive, such as .lzs and .pma.

     This version of the lha tool is part of Lhasa, a free implementation of the
     .lzh format.

COMMAND SYNTAX
     The lha tool has an unusual command syntax, compared  to  most  other  Unix
     commands.	The first parameter to the program specifies the command to per-
     form and all additional options. The second parameter specifies the path to
     the archive file to operate on. Following this is a list of  wildcard  pat-
     terns to match against the filenames of the archived files.

     The  first character of the command parameter specifies the command to per-
     form, which is one of the following:

     -l     List contents of the specified archive.

     -v     Verbosely list contents of the specified archive.

     -t     Test the integrity of the specified archive: decompress its contents
	    and check the CRC.

     -e or -x
	    Extract archive. Files are extracted to the current  working  direc-
	    tory unless the 'w' option is specified.

     -p     Extract  archive,  sending	decompressed files to stdout rather than
	    writing them to the filesystem as actual files. This is useful  when
	    used as part of a shell pipeline.

OPTIONS
     The  remainder  of  the command parameter is used to specify additional op-
     tions:

     q[012]
	    Quiet mode. Higher numbers suppress more output. Level 0  is  normal
	    operation.	If no number is specified, full suppression (level 2) is
	    used. The quiet option also turns  on  the	force  overwrite  option
	    ('f').

     f	    Force overwrite of existing files: do not prompt.

     i	    Ignore  paths  of  archived files: extract all archived files to the
	    same directory, ignoring subdirectories.

     n	    Do not perform any actual operations: instead, perform a dry run  of
	    the  requested  operation  and describe what would have been done on
	    standard output.

     v	    Verbose mode: causes extra information to  be  written  to	standard
	    output.

     w=dir  Specify destination directory for extracting files. This must be the
	    last option of the first parameter.

LIST OUTPUT FORMAT
     Lhasa  inherits  its list output format from the original Unix port of lha,
     and retains the same format for compatibility, since some tools  parse  the
     output.  Four different output formats are supported, depending on the com-
     mand line arguments:

     lha -l filename.lzh
	    Shows:  Unix permissions / OS type, UID/GID, uncompressed size, com-
	    pression ratio, modification time, filename.

     lha -lv filename.lzh
	    Two line output. First line shows the filename, second  line  shows:
	    Unix  permissions / OS type, UID/GID, uncompressed size, compression
	    ratio, modification time, filename, header level.

     lha -v filename.lzh
	    Shows: Unix permissions / OS type, UID/GID, compressed size,  uncom-
	    pressed size, compression ratio, compression format, checksum, modi-
	    fication time, filename.

     lha -vv filename.lzh
	    Two  line  output. First line shows the filename, second line shows:
	    Unix permissions / OS type, UID/GID, compressed  size,  uncompressed
	    size,  compression	ratio,	compression  format, checksum, long form
	    modification time, header level.

     The following are detailed descriptions of each of these fields:

     Unix permissions / OS type (PERMSSN)
	    For files compressed on a Unix system, this lists the permissions in
	    the same format that ls(1) uses when it is invoked with the  -l  op-
	    tion.  If  the file was not created on a Unix system, the OS type is
	    instead displayed in square brackets. Examples  are  "[MS-DOS]"  and
	    "[MacOS]";	the OS name never contains a space. If the file was cre-
	    ated on Microware OS-9, the permissions for that system will also be
	    shown.

     Unix user ID / group IDs (UID/GID)
	    For files compressed on a Unix system, this lists the user and group
	    IDs of the file, similar to the output seen from ls(1)  when  it  is
	    invoked  with  the -ln option. If the file was not created on a Unix
	    system, "*****/*****" is shown; see LIST FORMAT DIFFERENCES below.

     Compressed size (PACKED)
	    Size of the file in bytes as it is stored inside  the  archive  (not
	    including the header, which contains metadata about the file). If an
	    uncompressed format like -lh0- is used, this will be equal to SIZE.

     Uncompressed size (SIZE)
	    Size of the file in bytes before it was compressed.

     File compression ratio (RATIO)
	    Compressed	size as a percentage of uncompressed size. This measures
	    the effectiveness of the compression format; the  smaller  the  per-
	    centage,  the  better.  The value is (pessimistically) rounded up to
	    the next 0.1%. If an uncompressed format like -lh0-  is  used,  this
	    will be equal to 100%. For directories, "******" is shown. Note that
	    the  value	here  is  backwards  relative to unzip(1), which instead
	    shows the percentage of the original file size reduced.

     Compression format (METHOD)
	    The compression format used to store this file. See the  COMPRESSION
	    FORMATS section below.

     Checksum (CRC)
	    CRC16  checksum  of the file's contents in hexadecimal format. Warn-
	    ing: while this is useful for casually checking file  integrity,  it
	    is	only a 16-bit checksum and should not be considered reliable for
	    protecting files larger than a few kilobytes.

     Modification time (STAMP)
	    Date and time that the file was last modified before it  was  stored
	    in the archive. If the file doesn't have a timestamp stored, nothing
	    is	shown.	 The  output  can be in one of two forms: if the date is
	    within the past six months, the month, day and time  are  shown;  an
	    example  is "Aug 24 12:38". For older files, the month, day and year
	    are shown; an example is "Aug 24 2020".

     Long form modification time (STAMP)
	    This is only used when listing in the -vv format. The full date  and
	    timestamp  are  listed  in	numeric  form,	close to ISO 8601 format
	    (though not quite conformant with  that  standard).  An  example  is
	    "2020-08-24 12:38:25".

     Header level (LV)
	    Lha  header  format  used  to store this file. Supported formats are
	    0-3.

LIST FORMAT DIFFERENCES
     The list mode output from the original Unix lha tool was not designed to be
     machine-readable. Since some tools do try to parse the list output, Lhasa's
     list output has been deliberately tweaked slightly to make the output  more
     consistent and easier to parse.

     Here are the main differences:

     *	    If	a  file was not created on a Unix system, a spacer word is shown
	    in the UID/GID column. The original lha just showed whitespace.

     *	    The OS type for archives generated by MacLHA is  listed  as  "MacOS"
	    (no space).  The original lha showed "Mac OS".

     Note  that  in  general,  the approach of parsing text output is inherently
     fragile and prone to bugs. It's recommended that you instead use the proper
     API (liblhasa).

COMPRESSION FORMATS
     The following gives some basic description of the	various  different  sup-
     ported  compression  formats  (as	listed when using the list command docu-
     mented above).  All formats are variants on the LZSS compression algorithm.

     -lz4-  Uncompressed (stored) data, as used by the original LArc tool.  This
	    is not related to the LZ4 compression algorithm of the same name.

     -lz5-, -lzs-
	    Compression  formats  introduced with the original LArc tool.  -lzs-
	    uses a 2KiB sliding window while -lz5- uses a 4KiB window.

     -lhd-  Directory entry. No data is stored, only headers.

     -lh0-  Uncompressed (stored) data, as used in LHarc and LHa.

     -lh1-  Compression algorithm introduced with LHarc. This uses a 4KiB  slid-
	    ing window with dynamic Huffman encoding.

     -lh4-, -lh5-, -lh6-, -lh7-
	    New  algorithm  introduced	with  LHa (aka LHarc v2.0). The original
	    versions (-lh4- and -lh5-) used 8KiB and 16KiB sliding window sizes,
	    respectively.  Later versions introduced new  variants  with  larger
	    window sizes: -lh6- (64KiB) and -lh7- (128KiB).

     -lhx-  Variant  on  the -lh4- format listed above introduced by UNLHA32.dll
	    that extends the window size to 1MiB.

     -lk7-  Variant on the -lh4- format listed above that was introduced by  the
	    LHark  tool (a fork of LHa). This is actually named -lh7- within the
	    archive files, but Lhasa renames it  internally  to  avoid	clashing
	    with  the  other  algorithm  of the same name. Uses a 128KiB sliding
	    window, with some minor improvement to the algorithm.

     -pm0-  Uncompressed (stored) data, as used by the PMarc tool.

     -pm1-  Algorithm used by version 1 of the PMarc tool.

     -pm2-  Algorithm used by version 2 of the PMarc tool.

UNSUPPORTED FORMATS
     The following formats are not currently supported by  Lhasa  (but	possibly
     will be in the future):

     -lh2-, -lh3-
	    These formats can be decompressed by LHa v2.0 but the tool could not
	    actually  generate	archives with these formats; they appear to have
	    only been supported in beta versions before the v2.0 release.  As  a
	    result, few if any examples exist in the wild.

     -lh8-, -lh9-, -lha-, -lhb-, -lhc-, -lhe-
	    Extensions of the -lh4- format to even larger window sizes.

     -ll0-, -ll1-
	    Generated by ThunderSoft's PAKLEO utility (.pll).

     -sw0-, -sw1-
	    Used in SourceWare Archival Group's .swg (SWAG packet) format.

     -lz6-, -LD6-
	    Generated by LDarc and LDIFF (.lzd).

     -hf0-, -ah0-, -ari-, -arn-, -arw-
	    Generated by the Micrognosis Compression Archiver utility.

     -pc1-  Format generated by the PopCom! compression utility for CP/M.

     If you encounter examples of these in the wild, please get in touch.

EXAMPLES
     Here are some examples for how to invoke the program:

     lha -v foobar.lzs
	    List the contents of the file foobar.lzs (producing verbose output).

     lha -xf foobar.exe
	    Extract  the  contents  of a self-extracting archive file named foo-
	    bar.exe to the current directory, overwriting  existing  files  with
	    the same names if they exist.

     lha -xqw=/tmp foobar.lzh
	    Extract the contents of foobar.lzh to /tmp, overwriting any existing
	    files  found  there,  and  suppressing normal output (similar to how
	    other Unix tools such as cp(1) or tar(1) act silently by default).

WWW
     https://lhasa.soulsphere.org/

BUG REPORTS
     Bugs can be reported to the GitHub issue tracker:	https://github.com/frag-
     glet/lhasa

SEE ALSO
     unzip(1), tar(1), gzip(1), bzip2(1), xz(1), lzip(1)

HISTORY
     The  .lzh format originated with Kazuhiko Miki's MS-DOS archive tool, LArc,
     using the LZSS algorithm developed by Haruhiko Okumura, and the .lzs  file-
     name  extension.  The  container  format  was reused for LHarc, by Haruyasu
     Yoshizaki (Yoshi), which used a new algorithm named LZHUF and the .lzh  ex-
     tension. In later versions, LHarc was renamed to LHA and extended with more
     effective compression algorithms.

     Versions  of  the LHA tool were later ported to various different operating
     systems, including the Amiga, Atari, MacOS, OS/2  and  Unix.   A  tool  for
     MSX-DOS  named PMarc reused the container format with a new compression al-
     gorithm (.pma extension).

     The Unix version of the tool was developed by Masaru Oki, Nobutaka Watazaki
     and Tsugio Okamoto, but was released under a software license that does not
     conform to the Free Software or Open Source Definitions. Lhasa  was  devel-
     oped as a drop-in replacement that is Free Software and Open Source.

     The  name "LHA" and the .lzh filename extension are a reference to the com-
     pression algorithm: a combination of LempelaZivaStoreraSzymanski dictionary
     coding and Huffman encoding. Similar schemes are used in other  compression
     algorithms  such  as  Deflate  (used in gzip/zlib, PNG image files, and the
     .zip format).

BUGS
     The current version does not allow the creation of new archive files.

     Some obscure compression algorithms are not currently  supported  (see  the
     UNSUPPORTED FORMATS section above).

     The  tool	does not currently do text format conversion for non-ASCII file-
     names when listing the contents of archives. Non-ASCII characters	are  re-
     placed by a question mark.

AUTHOR
     Lhasa was written and is maintained by Simon Howard.

COPYRIGHT
     Copyright (C) 2011-2025 Simon Howard.

     Permission  to  use,  copy, modify, and/or distribute this software for any
     purpose with or without fee is hereby  granted,  provided	that  the  above
     copyright notice and this permission notice appear in all copies.

     THE  SOFTWARE  IS	PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     WITH REGARD TO THIS SOFTWARE  INCLUDING  ALL  IMPLIED  WARRANTIES	OF  MER-
     CHANTABILITY  AND	FITNESS.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES  WHATSO-
     EVER  RESULTING  FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
     CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNEC-
     TION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

									  lha(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=lhasa&sektion=1&manpath=FreeBSD+15.1-RELEASE+and+Ports>

home | help