5.K: Removing Directories | 5: Managing Files and Directories | 5.I: Moving Directories |
The command to
You should consider the
Try deleting the file a.out in the directory prog (we will regenerate
it later).
First go to the directory you want to delete the file from (Unix will take
the
Then remove the file (double check for typos before pressing
Type r
emove files in Unix is
rm. To remove a file type the command
rm
followed by the name of the file you wish to remove.
rm
command permanent. On the physics
cluster, your dot files are set up to warn you if a file is about
be removed, but you should not depend on this. In addition, most systems have
periodic backups, so if you remove something important you might be able to
get it from a backup. However, remove is very swift and efficient, and you
can easily lose a lot of work, so be very careful using
remove, and always check your commands for typos before
you press the return
key.
rm
command with filenames which involve pathnames, but this
is not recommended as it increases the chance of a typo.):
> cd development/prog
return
):
> rm -i a.out
Y
at the prompt.
Be extremely cautious if you decide to use wildcards with this command. The
command rm temp.*
removes all of the files starting with "temp.",
the command rm temp. *
removes the file "temp." and then
removes all files in the directory.
Unlike cp
and mv, the command to
remove directories
is not the same as the command to remove files.
5.K: Removing Directories
5: Managing Files and Directories