OSU Computational Physics - Landau Research Group (nacse) -
Next 5.K: Removing Directories  Up 5: Managing Files and Directories  Prev 5.I: Moving Directories  Contents

Basic

§ 5.J:  Removing Files


The command to remove files in Unix is rm. To remove a file type the command rm followed by the name of the file you wish to remove.

You should consider the 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.

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 rm command with filenames which involve pathnames, but this is not recommended as it increases the chance of a typo.):

> cd development/prog

Then remove the file (double check for typos before pressing return):

> rm -i a.out

Type 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.


Next 5.K: Removing Directories  Up 5: Managing Files and Directories