Section 3.16. Renaming a File: mv


[Page 58]

3.16. Renaming a File: mv

Now that I'd created the first draft of my lyrics, I wanted to create a few more experimental versions. To indicate that the file "heart" was really the first generation of many versions to come, I decided to rename it "heart.ver1" by using the mv utility, which works as described in Figure 3-19.

Figure 3-19. Description of the mv command.

Utility: mv -i oldFileName newFileName

mv -i {fileName}* directoryName

mv -i oldDirectoryName newDirectoryName

The first form of mv renames oldFileName as newFileName. If the label newFileName already exists, it is replaced. The second form allows you to move a collection of files to a directory, and the third form allows you to move an entire directory. None of these options actually moves the physical contents of a file if the destination location is within the same file system as the original; instead, they just move labels around the hierarchy. mv is therefore a very fast utility. The -i option prompts you for confirmation if newFileName already exists.


Here's how I renamed the file using the first form of the mv utility:

$ mv heart heart.ver1         ...rename to "heart.ver1". $ ls heart.ver1 $ _ 


The second and third forms of the mv utility are illustrated later in this chapter.




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net