next up previous contents
Next: File properties (ls -l) Up: Files and the File Previous: Removing a directory (rmdir,   Contents

Moving directories (mv)

It is with directories that the command mv is really useful. You can move one directory into another, thus creating a subdirectory. You can change the name of a directory or move a file from one directory to another. Do not try to move a directory into an ordinary file; you will get an error message. The format for this command is:

mv filename directory
or
mv directory1 directory2

In the first situation, a file is moved into the designated directory. In the latter case, two results are possible. If directory2 does not exist, directory1 has its name changed to directory2. If directory2 does exist, directory1 becomes a subdirectory of directory2, i.e. it is moved into directory2. Note that if these had been ordinary files, directory2 would have been wiped out by this command.



h.stilmack@jach.hawaii.edu