COMPRESS(1)                POSIX Programmer's Manual               COMPRESS(1)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       compress -- compress data

SSYYNNOOPPSSIISS
       compress [[-fv]] [[-b _b_i_t_s]] [[_f_i_l_e...]]

       compress [[-cfv]] [[-b _b_i_t_s]] [[_f_i_l_e]]

DDEESSCCRRIIPPTTIIOONN
       The _c_o_m_p_r_e_s_s utility shall attempt to reduce the size of the named
       files by using adaptive Lempel-Ziv coding algorithm.

       NNoottee::     Lempel-Ziv is US Patent 4464650, issued to William Eastman,
                 Abraham Lempel, Jacob Ziv, Martin Cohn on August 7th, 1984,
                 and assigned to Sperry Corporation.

                 Lempel-Ziv-Welch compression is covered by US Patent 4558302,
                 issued to Terry A. Welch on December 10th, 1985, and assigned
                 to Sperry Corporation.

       On systems not supporting adaptive Lempel-Ziv coding algorithm, the
       input files shall not be changed and an error value greater than two
       shall be returned. Except when the output is to the standard output,
       each file shall be replaced by one with the extension ..ZZ.  If the
       invoking process has appropriate privileges, the ownership, modes,
       access time, and modification time of the original file are preserved.
       If appending the ..ZZ to the filename would make the name exceed
       {NAME_MAX} bytes, the command shall fail. If no files are specified,
       the standard input shall be compressed to the standard output.

OOPPTTIIOONNSS
       The _c_o_m_p_r_e_s_s utility shall conform to the Base Definitions volume of
       POSIX.1-2017, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following options shall be supported:

       --bb _b_i_t_s   Specify the maximum number of bits to use in a code. For a
                 conforming application, the _b_i_t_s argument shall be:


                     9 <= _b_i_t_s <= 14

                 The implementation may allow _b_i_t_s values of greater than 14.
                 The default is 14, 15, or 16.

       --cc        Cause _c_o_m_p_r_e_s_s to write to the standard output; the input
                 file is not changed, and no ..ZZ files are created.

       --ff        Force compression of _f_i_l_e, even if it does not actually
                 reduce the size of the file, or if the corresponding _f_i_l_e..ZZ
                 file already exists. If the --ff option is not given, and the
                 process is not running in the background, the user is
                 prompted as to whether an existing _f_i_l_e..ZZ file should be
                 overwritten. If the response is affirmative, the existing
                 file will be overwritten.

       --vv        Write the percentage reduction of each file to standard
                 error.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of a file to be compressed.

SSTTDDIINN
       The standard input shall be used only if no _f_i_l_e operands are
       specified, or if a _f_i_l_e operand is ''--''.

IINNPPUUTT FFIILLEESS
       If _f_i_l_e operands are specified, the input files contain the data to be
       compressed.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of
       _c_o_m_p_r_e_s_s:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2017, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_O_L_L_A_T_E
                 Determine the locale for the behavior of ranges, equivalence
                 classes, and multi-character collating elements used in the
                 extended regular expression defined for the yyeesseexxpprr locale
                 keyword in the _L_C___M_E_S_S_A_G_E_S category.

       _L_C___C_T_Y_P_E  Determine the locale for the interpretation of sequences of
                 bytes of text data as characters (for example, single-byte as
                 opposed to multi-byte characters in arguments), the behavior
                 of character classes used in the extended regular expression
                 defined for the yyeesseexxpprr locale keyword in the _L_C___M_E_S_S_A_G_E_S
                 category.

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale used to process affirmative responses,
                 and the locale used to affect the format and contents of
                 diagnostic messages, prompts, and the output from the --vv
                 option written to standard error.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       If no _f_i_l_e operands are specified, or if a _f_i_l_e operand is ''--'', or if
       the --cc option is specified, the standard output contains the compressed
       output.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic and prompt
       messages and the output from --vv.

OOUUTTPPUUTT FFIILLEESS
       The output files shall contain the compressed output. The format of
       compressed files is unspecified and interchange of such files between
       implementations (including access via unspecified file sharing
       mechanisms) is not required by POSIX.1-2008.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

        1    An error occurred.

        2    One or more files were not compressed because they would have
             increased in size (and the --ff option was not specified).

       >2    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       The input file shall remain unmodified.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The amount of compression obtained depends on the size of the input,
       the number of _b_i_t_s per code, and the distribution of common substrings.
       Typically, text such as source code or English is reduced by 50-60%.
       Compression is generally much better than that achieved by Huffman
       coding or adaptive Huffman coding (_c_o_m_p_a_c_t), and takes less time to
       compute.

       Although _c_o_m_p_r_e_s_s strictly follows the default actions upon receipt of
       a signal or when an error occurs, some unexpected results may occur. In
       some implementations it is likely that a partially compressed file is
       left in place, alongside its uncompressed input file. Since the general
       operation of _c_o_m_p_r_e_s_s is to delete the uncompressed file only after the
       ..ZZ file has been successfully filled, an application should always
       carefully check the exit status of _c_o_m_p_r_e_s_s before arbitrarily deleting
       files that have like-named neighbors with ..ZZ suffixes.

       The limit of 14 on the _b_i_t_s option-argument is to achieve portability
       to all systems (within the restrictions imposed by the lack of an
       explicit published file format). Some implementations based on 16-bit
       architectures cannot support 15 or 16-bit uncompression.

EEXXAAMMPPLLEESS
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _u_n_c_o_m_p_r_e_s_s, _z_c_a_t

       The Base Definitions volume of POSIX.1-2017, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                          COMPRESS(1)
