->Title Page
->Intro
->Unix
-->Overview
-->File Structure
-->Online Manual
-->Basic Commands
--->Logging In
--->Password
--->Getting Out
--->Listing files
--->Catenate
--->Paging
--->Copying
--->Removing
->Renaming files
--->Directory trees
--->Make/Remove Directories
-->Additional Commands
-->Login files
-->Special characters
-->Miscellaneous Tips
-->Things to try
->Vi editor
->Mirror sites
->Further reading

[ Up ]
[Prev][Home][Next]
[Author]

Unix ---> Renaming and moving files and directories (mv)

The mv (move) command moves a file from the first argument to the second argument, e.g.


    mv neatguy tidyguy
moves the contents of neatguy to the contents of tidyguy. This command reminds me of the time Chicago Bulls forward Stacey King said:

I'll always remember this as the night that Michael Jordan and I combined to score 70 points.
King said that after scoring one point in a game in which Jordan scored sixty-nine.

All that really happened was that the file's name was changed. The reason it is called the move instead of rename or something like that is that you can include pathnames (just like you have done before in cp and rm). Including pathnames allows you to move a file into a different directory, hence the name. The mv command works on both filenames and directory names exactly the same way.

The -i flag works here just like it worked with cp. Setting this flag will prompt you before it moves a file on top of one that already exists.

WARNING: for (i = 0 ; i <= 50 ; i++) printf("Don't "); don't use wildcards with the mv command unless the destination is a directory. The mv command doesn't know what to do if you tell it to move a bunch of files into a single filename and so it will move all the files you selected on top of each other.

Please notify owners of webpages with outdated links to these pages

Find this site useful? Want to give something back?

© 1993-2001 Christopher C. Taylor