RM, DELETE(1,C) AIX Commands Reference RM, DELETE(1,C)
-------------------------------------------------------------------------------
rm, delete
PURPOSE
Removes files or directories.
SYNTAX
one of
+--------+ +------------+
| rm |---| +----+ |--- file ---|
| delete | +---| -f |---+ ^ |
+--------+ ^ | -i | | +--------+
| | -r | |
| | -- | |
| | -s | |
| +----+ |
+--------+
DESCRIPTION
The rm (delete) command removes the entries for files from a directory. If an
entry is the last link to a file, it is destroyed. To remove a file, you must
have write permission in its directory. If the directory has been marked with
the saved text permission mode (SVTX), only the owner of the file or directory
or superuser can remove the file. If a file has no write permission and
standard input is a work station, rm displays the file permission code and
reads a line from standard input. If that line begins with "y", rm deletes the
file; otherwise it remains.
Note: When you use the install command to install files, a hidden directory is
created. To remove these files, use rm -rf.
FLAGS
-f Does not prompt before removing a write-protected file.
-i Prompts you before deleting each file. When you use both -i and -r
together, rm also asks if you want to examine directories.
-r Permits recursive removal of directories and their contents (for cases where
file is a directory).
-s Permits the removal of symbolic links from a directory in a
system-replicated file system. This option is ignored if the specified
files are not symbolic links, and is unnecessary if the r option is used.
Processed November 8, 1990 RM, DELETE(1,C) 1
RM, DELETE(1,C) AIX Commands Reference RM, DELETE(1,C)
-- Indicates that the arguments following this flag are to be interpreted as
file names. This null flag allows the specification of file names that
start with a minus (-).
EXAMPLES
1. To delete a file:
rm myfile
If there is another link to this file, the file remains under that name,
but the name "myfile" is removed. If "myfile" is the only link, the file
itself is deleted.
2. To delete a file silently:
rm -f core
This removes core without asking any questions or displaying any error
messages. This is normally used in shell procedures. It prevents
confusing messages from being displayed when deleting files that may or may
not exist.
3. To delete files one by one:
rm -i mydir/*
This interactively asks you if you want to remove each file. After each
file name is displayed, enter "y" to delete the file, or press Enter alone
to keep it.
4. To delete a directory tree:
rm -ir manual
This recursively removes the contents of all subdirectories of "manual",
then removes "manual" itself, asking if you want to remove each file. For
example:
Processed November 8, 1990 RM, DELETE(1,C) 2
RM, DELETE(1,C) AIX Commands Reference RM, DELETE(1,C)
You: rm -ir manual
System: rm:remove directory manual?
You: y
System: rm:remove directory manual/draft1?
You: y
System: rm:remove manual/draft1/chapter1?
You: y
System: rm:delete manual/draft1/chapter2?
You: y
System: rm:remove manual/draft2?
You: n
System: rm: cannot remove directory
Here, because manual contains directories, rm asks for permission to search
these directories for files to delete. Then, for each of these
directories, rm asks for permission to delete the files in that directory
(manual/draft1/chapter1 and manual/draft1/chapter2). Next, rm asks for
permission to delete the directory manual/draft1. This is repeated for the
other subdirectory (manual/draft2), and then rm asks for permission to
delete manual. Because you denied permission to delete manual/draft2, rm
will not delete manual.
5. To delete a symbolic link from a directory in a system-replicated file
system:
rm -s /etc/symlink
RELATED INFORMATION
See the following commands: "del" and "ln."
See the unlink system call in AIX Operating System Technical Reference.
Processed November 8, 1990 RM, DELETE(1,C) 3