RM(1)                      POSIX Programmer's Manual                     RM(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
       rm -- remove directory entries

SSYYNNOOPPSSIISS
       rm [[-fiRr]] _f_i_l_e...

DDEESSCCRRIIPPTTIIOONN
       The _r_m utility shall remove the directory entry specified by each _f_i_l_e
       argument.

       If either of the files dot or dot-dot are specified as the basename
       portion of an operand (that is, the final pathname component) or if an
       operand resolves to the root directory, _r_m shall write a diagnostic
       message to standard error and do nothing more with such operands.

       For each _f_i_l_e the following steps shall be taken:

        1. If the _f_i_l_e does not exist:

            a. If the --ff option is not specified, _r_m shall write a diagnostic
               message to standard error.

            b. Go on to any remaining _f_i_l_e_s.

        2. If _f_i_l_e is of type directory, the following steps shall be taken:

            a. If neither the --RR option nor the --rr option is specified, _r_m
               shall write a diagnostic message to standard error, do nothing
               more with _f_i_l_e, and go on to any remaining files.

            b. If the --ff option is not specified, and either the permissions
               of _f_i_l_e do not permit writing and the standard input is a
               terminal or the --ii option is specified, _r_m shall write a prompt
               to standard error and read a line from the standard input. If
               the response is not affirmative, _r_m shall do nothing more with
               the current file and go on to any remaining files.

            c. For each entry contained in _f_i_l_e, other than dot or dot-dot,
               the four steps listed here (1 to 4) shall be taken with the
               entry as if it were a _f_i_l_e operand. The _r_m utility shall not
               traverse directories by following symbolic links into other
               parts of the hierarchy, but shall remove the links themselves.

            d. If the --ii option is specified, _r_m shall write a prompt to
               standard error and read a line from the standard input. If the
               response is not affirmative, _r_m shall do nothing more with the
               current file, and go on to any remaining files.

        3. If _f_i_l_e is not of type directory, the --ff option is not specified,
           and either the permissions of _f_i_l_e do not permit writing and the
           standard input is a terminal or the --ii option is specified, _r_m
           shall write a prompt to the standard error and read a line from the
           standard input. If the response is not affirmative, _r_m shall do
           nothing more with the current file and go on to any remaining
           files.

        4. If the current file is a directory, _r_m shall perform actions
           equivalent to the _r_m_d_i_r() function defined in the System Interfaces
           volume of POSIX.1-2008 called with a pathname of the current file
           used as the _p_a_t_h argument. If the current file is not a directory,
           _r_m shall perform actions equivalent to the _u_n_l_i_n_k() function
           defined in the System Interfaces volume of POSIX.1-2008 called with
           a pathname of the current file used as the _p_a_t_h argument.

           If this fails for any reason, _r_m shall write a diagnostic message
           to standard error, do nothing more with the current file, and go on
           to any remaining files.

       The _r_m utility shall be able to descend to arbitrary depths in a file
       hierarchy, and shall not fail due to path length limitations (unless an
       operand specified by the user exceeds system limitations).

OOPPTTIIOONNSS
       The _r_m 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:

       --ff        Do not prompt for confirmation. Do not write diagnostic
                 messages or modify the exit status in the case of nonexistent
                 operands. Any previous occurrences of the --ii option shall be
                 ignored.

       --ii        Prompt for confirmation as described previously. Any previous
                 occurrences of the --ff option shall be ignored.

       --RR        Remove file hierarchies. See the DESCRIPTION.

       --rr        Equivalent to --RR.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of a directory entry to be removed.

SSTTDDIINN
       The standard input shall be used to read an input line in response to
       each prompt specified in the STDOUT section. Otherwise, the standard
       input shall not be used.

IINNPPUUTT FFIILLEESS
       None.

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

       _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_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) and the
                 behavior of character classes within regular expressions 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 and prompts 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
       Prompts shall be written to standard error under the conditions
       specified in the DESCRIPTION and OPTIONS sections. The prompts shall
       contain the _f_i_l_e pathname, but their format is otherwise unspecified.
       The standard error also shall be used for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Each directory entry was successfully removed, unless its removal
             was canceled by a non-affirmative response to a prompt for
             confirmation.

       >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
       The _r_m utility is forbidden to remove the names dot and dot-dot in
       order to avoid the consequences of inadvertently doing something like:

           rrmm --rr ..**

       Some implementations do not permit the removal of the last link to an
       executable binary file that is being executed; see the [[EEBBUUSSYY]] error in
       the _u_n_l_i_n_k() function defined in the System Interfaces volume of
       POSIX.1-2008. Thus, the _r_m utility can fail to remove such files.

       The --ii option causes _r_m to prompt and read the standard input even if
       the standard input is not a terminal, but in the absence of --ii the mode
       prompting is not done when the standard input is not a terminal.

EEXXAAMMPPLLEESS
        1. The following command:

               rrmm aa..oouutt ccoorree

           removes the directory entries: aa..oouutt and ccoorree.

        2. The following command:

               rrmm --RRff jjuunnkk

           removes the directory jjuunnkk and all its contents, without prompting.

RRAATTIIOONNAALLEE
       For absolute clarity, paragraphs (2b) and (3) in the DESCRIPTION of _r_m
       describing the behavior when prompting for confirmation, should be
       interpreted in the following manner:

           iiff ((((NNOOTT ff__ooppttiioonn)) AANNDD
               ((((nnoott__wwrriittaabbllee AANNDD iinnppuutt__iiss__tteerrmmiinnaall)) OORR ii__ooppttiioonn))))

       The exact format of the interactive prompts is unspecified. Only the
       general nature of the contents of prompts are specified because
       implementations may desire more descriptive prompts than those used on
       historical implementations. Therefore, an application not using the --ff
       option, or using the --ii option, relies on the system to provide the
       most suitable dialog directly with the user, based on the behavior
       specified.

       The --rr option is historical practice on all known systems. The synonym
       --RR option is provided for consistency with the other utilities in this
       volume of POSIX.1-2008 that provide options requesting recursive
       descent through the file hierarchy.

       The behavior of the --ff option in historical versions of _r_m is
       inconsistent. In general, along with ``forcing'' the unlink without
       prompting for permission, it always causes diagnostic messages to be
       suppressed and the exit status to be unmodified for nonexistent
       operands and files that cannot be unlinked. In some versions, however,
       the --ff option suppresses usage messages and system errors as well.
       Suppressing such messages is not a service to either shell scripts or
       users.

       It is less clear that error messages regarding files that cannot be
       unlinked (removed) should be suppressed. Although this is historical
       practice, this volume of POSIX.1-2008 does not permit the --ff option to
       suppress such messages.

       When given the --rr and --ii options, historical versions of _r_m prompt the
       user twice for each directory, once before removing its contents and
       once before actually attempting to delete the directory entry that
       names it. This allows the user to ``prune'' the file hierarchy walk.
       Historical versions of _r_m were inconsistent in that some did not do the
       former prompt for directories named on the command line and others had
       obscure prompting behavior when the --ii option was specified and the
       permissions of the file did not permit writing. The POSIX Shell and
       Utilities _r_m differs little from historic practice, but does require
       that prompts be consistent. Historical versions of _r_m were also
       inconsistent in that prompts were done to both standard output and
       standard error. This volume of POSIX.1-2008 requires that prompts be
       done to standard error, for consistency with _c_p and _m_v, and to allow
       historical extensions to _r_m that provide an option to list deleted
       files on standard output.

       The _r_m utility is required to descend to arbitrary depths so that any
       file hierarchy may be deleted. This means, for example, that the _r_m
       utility cannot run out of file descriptors during its descent (that is,
       if the number of file descriptors is limited, _r_m cannot be implemented
       in the historical fashion where one file descriptor is used per
       directory level). Also, _r_m is not permitted to fail because of path
       length restrictions, unless an operand specified by the user is longer
       than {PATH_MAX}.

       The _r_m utility removes symbolic links themselves, not the files they
       refer to, as a consequence of the dependence on the _u_n_l_i_n_k()
       functionality, per the DESCRIPTION. When removing hierarchies with --rr
       or --RR, the prohibition on following symbolic links has to be made
       explicit.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _r_m_d_i_r

       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

       The System Interfaces volume of POSIX.1-2008, _r_e_m_o_v_e(), _r_m_d_i_r(),
       _u_n_l_i_n_k()

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                                RM(1)
