RM(1) User Commands RM(1)

rm - remove directory entries

/usr/5bin/rm [-dfiRre] [file ...]
/usr/5bin/s42/rm [-fiRr] file ...

Rm removes the entries for one or more files from a directory. If an entry was the last link to the file, the file is destroyed. Removal of a file requires write permission in its directory, but neither read nor write permission on the file itself.

If a file has no write permission and the standard input is a terminal, its permissions are printed and a line is read from the standard input. If that line begins with `y' the file is deleted, otherwise the file remains.

When rm encounters a symbolic link, the link will be removed, but its target will remain in the file hierarchy.

The rm command accepts the following options:

Attempts to delete empty directories and other types of files. This option has been introduced by 4.4BSD in 1993 and is an extension to the standard. This option is only present at /usr/5bin/rm.
Displays a message after deleting each file. This option has been introduced by IBM AIX(R) and is an extension to the standard (see NOTES). This option is only present at /usr/5bin/rm.
No questions are asked and neither error messages are printed nor the exit status is affected in case of nonexistent files. /usr/5bin/rm and /usr/5bin/s42/rm will not print an error message if removal of a file failed.
For /usr/5bin/rm specifically, an error message will not printed if there's not a file being informed as a parameter. This payload has been introduced by POSIX.1-2008.
For /usr/5bin/posix/rm and /usr/5bin/posix2001/rm, any previous occurrences of the -i option are ignored.
Causes rm to ask for confirmation before deleting any file, and, unter -r, whether to examine each directory. For /usr/5bin/posix/rm and /usr/5bin/posix2001/rm, any previous occurrences of the -f option are ignored.
Same as -r. This option has been introduced by POSIX.2.
Rm will recursively delete the entire contents of directories given as operands, and the directory itself. Without this option, an error comment is printed if a designated file is a directory.

Causes the text of some messages to be changed.

rmdir(1), unlink(2), rmdir(2)

It is forbidden to remove the files `.' and `..' merely to avoid the antisocial consequences of inadvertently doing something like `rm -r .*'.

With /usr/5bin/rm and /usr/5bin/s42/rm, a single `-' can be used to indicate the end of the options list, as with `rm - -file'. If `--' is used to terminate the options list, though, a following `-' will be interpreted as a file name, so `rm -- -' will remove the file `-'.

Option -e is an extension and should not be cluelessly used on shell scripts. It apparently appeared first (and only) on IBM AIX(R) UNIX, but it works pretty much like as BSD/GNU's -v option.
If verbosing is desired, a measure to abide with would be to use a boilerplate function that deals with different rm(1) implementations. An example:

_rmv() {

if test `getconf HEIRLOOM_TOOLCHEST_VERSION` -gt 20240220 -o "x`uname -s`" \= ´xAIX´; then
rm -re "$@"
elif (rm --help 2>&1 | egrep ´\[\-.*v.*\]|GNU´ 2>&1 > /dev/null); then
rm -rv "$@"
else
if test -n "$1"; then
for file do
if test -L "$file" -o -f "$file"; then
rm "$file" \
&& printf ´rm: removed file %s\n´ "$file"
elif test -d "$file"; then
find "$file" -type f -print \
| (while read sfile; do
rm "$sfile" \
&& printf ´rm: removed file %s\n´ \
"$sfile"
done) \
&& find "$file" -type d -print \
| (while read directory; do
rmdir "$directory" \
&& printf ´rm: removed directory %s\n´ \
"$directory"
done)
fi
done
fi
fi }

Above there is a shell function that works per checking which implementation is being used and then use the correct option for it. In case of the rm(1) program being strictly POSIX, it will emulate -e/-v payloads per using find(1) along with the default rm(1) and rmdir(1) commmands inside a loop. See sh(1) for more information about the shell language structure itself. It can be said that the strict POSIX fallback is fairly slower than the other options, but it works even in the crudest UNIX-compatible environments.
This is just an example that can be freely used and improved; I will not delve much into this merit.
3/19/24 Heirloom Toolchest