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:
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 }
3/19/24 | Heirloom Toolchest |