rm, unlink

Remove directory entries
and maybe the file freeing up space.

rm [-dfiPRrvW] file
unlink file
(safer less powerful)

Remove files

Caution rm * deletes all the files in the current directory.
Before hand (like now)     touch 00-safe; chmod a-w 00-safe # which will stop rm with message:
override r--r--r-- usrn/gropn for 0`0-safe?

-d remove directories and other types of files.
-f force i.e. without prompting for confirmation, ignoring of the file's permissions, does not exist, do not display a diagnostic message or modify the exit status to reflect an error. The overrides previous -i (interactive).
-i Interactively confirm removal of each file. Overrides previous -f (force)
-P Purge securely Overwrite regular files with FF, then 00, and then FF Fgain, before they are deleted.
-R
-r
Recursively remove the file hierarchy rooted in each file argument.
implies -d (directories, …).
With -i (interactive) the user must confirm each directory's contents and directory
-v Be verbose when deleting files, showing them as they are removed.
-W Undelete. Only in a union FS to recover files covered by whiteouts

Removes symbolic links, not the files referenced.

Current and parrent directoy cannot be removed by specifing . or .. .

unlink, accepts only one non-directory argument and options.

Exits 0 if all of the named files or file hierarchies were removed, or with -f (force) and all of the existing files or file hierarchies were removed.

If the permissions do not permit writing and the STDIN is a terminal, the user is prompted on the STDERR, for confirmation.

Accepts -- to stop option list and allows the removal of names begining with -.
For example:

 rm -- -filename
Or by using a path reference. For example:
 rm /home/user/-filename
rm ./-filename
If the file (or a link ) was opened by another process the directory entry is removed but, since the inode is still in use, the file will not be removed nor will the space become available untill all inodes are closed!
If you suspect that other processes have the inode in use, BEFORE removing the directory
cat /dev/null >fileAboutToBeDeleted
.

As a failsafe add an rm script to a directory in the path which issues a cat /dev/null > $* before a rm


rmdir

rmdir [-pv] directory

Removes empty directory entries.

Arguments are processed in the order given. In order to remove both a parent directory and a subdirectory of that parent, the subdirectory must be specified first so the parent directory is empty when rmdir tries to remove it.

-p Directores are treated as pathnames of which all empty components will be removed starting with the last most component. (See rm for fully non-discriminant recursive removal.)
-v verbose, listing each directory as it is removed.

EXIT STATUS

0 Empty directories were removed
>0 An error occurred.

EXAMPLES

Remove the MyEmptyDirectory.
 > rmdir MyEmptyDirectory
Remove all directories up to and including priorRun, stopping at the first non-empty directory
> rmdir -p priorRun/Qtr*/week*
See undelete, unlink, fts, getopt, symlin)