Sunday, November 2, 2008

move/rename files (mv)

move files or folders with the mv command
mv source destination

to move a file called bar.txt from a folder called /home/documents to a
folder called /home/documents/foo, type
$ mv /home/documents/bar.txt /home/documents/foo/

if you are in the directory /home/documents simply type
$ mv bar.txt foo

to move /home/documents/foo/bar.txt back to /home/documents type if you
are in the /home/documents/foo directory
$ mv bar.txt ..

to rename bar.txt to help.txt
$ mv bar.txt help.txt

note that if the name you want to rename to matches exactly an existing
directory, you cannot rename it. you cannot have a file and a folder
with the same name.

These example work exactly the same for moving and renaming directories

No comments: