SPLIT(1)                   POSIX Programmer's Manual                  SPLIT(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
       split -- split files into pieces

SSYYNNOOPPSSIISS
       split [[-l _l_i_n_e___c_o_u_n_t]] [[-a _s_u_f_f_i_x___l_e_n_g_t_h]] [[_f_i_l_e[[_n_a_m_e]]]]

       split -b _n[[k|m]] [[-a _s_u_f_f_i_x___l_e_n_g_t_h]] [[_f_i_l_e[[_n_a_m_e]]]]

DDEESSCCRRIIPPTTIIOONN
       The _s_p_l_i_t utility shall read an input file and write one or more output
       files.  The default size of each output file shall be 1000 lines. The
       size of the output files can be modified by specification of the --bb or
       --ll options. Each output file shall be created with a unique suffix. The
       suffix shall consist of exactly _s_u_f_f_i_x___l_e_n_g_t_h lowercase letters from
       the POSIX locale. The letters of the suffix shall be used as if they
       were a base-26 digit system, with the first suffix to be created
       consisting of all ''aa'' characters, the second with a ''bb'' replacing the
       last ''aa'', and so on, until a name of all ''zz'' characters is created. By
       default, the names of the output files shall be ''xx'', followed by a two-
       character suffix from the character set as described above, starting
       with ""aaaa"", ""aabb"", ""aacc"", and so on, and continuing until the suffix ""zzzz"",
       for a maximum of 676 files.

       If the number of files required exceeds the maximum allowed by the
       suffix length provided, such that the last allowable file would be
       larger than the requested size, the _s_p_l_i_t utility shall fail after
       creating the last file with a valid suffix; _s_p_l_i_t shall not delete the
       files it created with valid suffixes. If the file limit is not
       exceeded, the last file created shall contain the remainder of the
       input file, and may be smaller than the requested size.

OOPPTTIIOONNSS
       The _s_p_l_i_t utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _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:

       --aa _s_u_f_f_i_x___l_e_n_g_t_h
                 Use _s_u_f_f_i_x___l_e_n_g_t_h letters to form the suffix portion of the
                 filenames of the split file. If --aa is not specified, the
                 default suffix length shall be two. If the sum of the _n_a_m_e
                 operand and the _s_u_f_f_i_x___l_e_n_g_t_h option-argument would create a
                 filename exceeding {NAME_MAX} bytes, an error shall result;
                 _s_p_l_i_t shall exit with a diagnostic message and no files shall
                 be created.

       --bb _n      Split a file into pieces _n bytes in size.

       --bb _nkk     Split a file into pieces _n*1024 bytes in size.

       --bb _nmm     Split a file into pieces _n*1048576 bytes in size.

       --ll _l_i_n_e___c_o_u_n_t
                 Specify the number of lines in each resulting file piece. The
                 _l_i_n_e___c_o_u_n_t argument is an unsigned decimal integer. The
                 default is 1000. If the input does not end with a <newline>,
                 the partial line shall be included in the last output file.

OOPPEERRAANNDDSS
       The following operands shall be supported:

       _f_i_l_e      The pathname of the ordinary file to be split. If no input
                 file is given or _f_i_l_e is ''--'', the standard input shall be
                 used.

       _n_a_m_e      The prefix to be used for each of the files resulting from
                 the split operation. If no _n_a_m_e argument is given, ''xx'' shall
                 be used as the prefix of the output files. The combined
                 length of the basename of _p_r_e_f_i_x and _s_u_f_f_i_x___l_e_n_g_t_h cannot
                 exceed {NAME_MAX} bytes. See the OPTIONS section.

SSTTDDIINN
       See the INPUT FILES section.

IINNPPUUTT FFIILLEESS
       Any file can be used as input.

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

       _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-2008, _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_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 and input
                 files).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages 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
       Not used.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       The output files contain portions of the original input file;
       otherwise, unchanged.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _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
       None.

EEXXAAMMPPLLEESS
       In the following examples ffoooo is a text file that contains 5000 lines.

        1. Create five files, xxaaaa, xxaabb, xxaacc, xxaadd, and xxaaee:

               sspplliitt ffoooo

        2. Create five files, but the suffixed portion of the created files
           consists of three letters, xxaaaaaa, xxaaaabb, xxaaaacc, xxaaaadd, and xxaaaaee:

               sspplliitt --aa 33 ffoooo

        3. Create three files with four-letter suffixes and a supplied prefix,
           bbaarr__aaaaaaaa, bbaarr__aaaaaabb, and bbaarr__aaaaaacc:

               sspplliitt --aa 44 --ll 22000000 ffoooo bbaarr__

        4. Create as many files as are necessary to contain at most 20*1024
           bytes, each with the default prefix of xx and a five-letter suffix:

               sspplliitt --aa 55 --bb 2200kk ffoooo

RRAATTIIOONNAALLEE
       The --bb option was added to provide a mechanism for splitting files
       other than by lines. While most uses of the --bb option are for
       transmitting files over networks, some believed it would have
       additional uses.

       The --aa option was added to overcome the limitation of being able to
       create only 676 files.

       Consideration was given to deleting this utility, using the rationale
       that the functionality provided by this utility is available via the
       _c_s_p_l_i_t utility (see _c_s_p_l_i_t).  Upon reconsideration of the purpose of
       the User Portability Utilities option, it was decided to retain both
       this utility and the _c_s_p_l_i_t utility because users use both utilities
       and have historical expectations of their behavior. Furthermore, the
       splitting on byte boundaries in _s_p_l_i_t cannot be duplicated with the
       historical _c_s_p_l_i_t.

       The text ``_s_p_l_i_t shall not delete the files it created with valid
       suffixes'' would normally be assumed, but since the related utility,
       _c_s_p_l_i_t, does delete files under some circumstances, the historical
       behavior of _s_p_l_i_t is made explicit to avoid misinterpretation.

       Earlier versions of this standard allowed a --_l_i_n_e___c_o_u_n_t option. This
       form is no longer specified by POSIX.1-2008 but may be present in some
       implementations.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_s_p_l_i_t

       The Base Definitions volume of POSIX.1-2008, _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, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/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                  2013                             SPLIT(1)
