music |
| | OSdata.com |
mv
summary
This subchapter looks at mv, a UNIX (and Linux) command.
mv
This subchapter looks at mv, a UNIX (and Linux) command.
mv is used to move or rename a file.
rename a file
Use the mv command to rename a file. This example assumes you created the names and saved_name files in the quick tour subchapter.
$ mv saved_named old_names
$
Notice that the shell is once again silent with success. You can use the ls command to confirm that the rename really was made.
$ ls
Desktop Movies Send registration
Documents Music Sites
Downloads Pictures names
Library Public old_names
$
common error
A common error is the source file not existing (often because of a typing or speling error).
interactive confirmation
Use the -i option to have an interactive confirmation before overwriting an existing file. Note that this does not seem to work on Mac OS X Mountain Lion.
$ mv -i names saved_names
overwrite saved_names? (y/n [n]) n
not overwritten
$
force overwrites
Use the -f option to force rename (mv) to overwrite any file with a matching name. This is the same as the default action of the mv command.
$ mv -f names saved_names
prevent overwrites
Use the -n option to prevent rename (mv) from overwriting any file with a matching name.
$ mv -n names saved_names
PC-DOS equivalent
mv is the UNIX equivalent of the MS-DOS or PC-DOS command REN. You can add the PC-DOS equivalent to your shell session with the alias command. To make the change permanent, add the following line to the .bashrc file in your home directory.
$ alias REN="mv"
other
On November 8, 2010, Ramesh Natarajan named this the number 29 most frequently used UNIX/Linux command at this web page 50 Most Frequently Used UNIX / Linux Commands (With Examples).
In June 2009, Ken Milberg named this command as one of the Top 50 universal UNIX commands at this web page Top 50 Universal INIX commands. Note that this web page requires agreeing to be spammed before you can read it.
comments, suggestions, corrections, criticisms
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
Names and logos of various OSs are trademarks of their respective owners.