next up previous
Next: ChangingCreating and Removing Up: USING UNIX Previous: Listing the Contents of

Moving, Copying and Removing Files (mv, cp, rm)

The command mv moves (or renames) files. The simplest form of use is mv oldfilename newfilename. It will also move directories. If you use it in the form mv filename directoryname it will move the file into the named directory keeping its old name. To change its name you do mv oldfilename directoryname/newfilename

Copying files is similar to moving them but you use cp instead of mv.

Watch out! If you move a file and there already exists a file with your newfilename, that file will be destroyed. If you do not like this feature put the line
set noclobber
in your .cshrc file.

To remove a file you rm filename. On UNIX systems with shared file systems once you remove it it is gone. If you don't like this you can create a safer alias as instructed below. There are also regular backups made of files, but an ounce of prevention is worth a pound of cure.