Moving or renaming a file
You can use the mv command to move or rename a file.
The format for this command is
mv file1 file2
where
file1 is the name (and path, if necessary) of the file
that will be moved
file2 is either the new location or new name of file1.
The DOS equivalent of this command is ren or rename.
To minimize the need to move a file around, save it directly
from the program that created it (e.g., a word
processor) into an appropriate
directory.
An
easy and
foolproof
way
to
do
this is to always specify the complete path from your home directory.
For example, to save a file named phonelist into
your home directory, save it as
~/phonelist.
To save a document named essay.doc into
your biology subdirectory in your home directory, save it as
~/biology/essay.doc .
Here are some examples of files being moved:
mv letter.txt proposal.txt
"letter.txt" is renamed "proposal.txt" and remains in the current directory.
mv proposal.txt work/
"proposal.txt" is moved from the current directory to the "work" directory.
You can indicate directory paths using the following abbreviations:
. current directory
.. parent (previous) directory
~ home directory
For example, entering mv work/proposal.txt ./letter will
rename "proposal.txt" to "letter" and move it from the "work" directory
to the current directory.
Entering mv work/proposal.txt ../proposal.txt will move
the file "proposal.txt" from the "work" directory to its parent directory.
Likewise, entering mv work/letter.txt ~/letter.txt will
move the file "letter.txt" from the "work" directory to the home directory
of the user.
Last modified
July 20, 2004
by cawalker
|