MV COMMAND OPTIONS

The mv command doesn't include many options, and the options are infrequently used. But many of them offer useful functionality that may come in handy for you.

The -f or --force option overwrites existing destination files without asking for confirmation. Most Linux distributions are configured so that mv automatically requests confirmation when a command results in the destruction of an existing destination file. This prevents users from accidentally destroying their data by means of a poorly thought-out mv command. However, replying to the confirmation prompt can be annoying when you are certain you know what you are doing and you are moving more than one file at a time. The following example suppresses confirmation when moving an entire directory's worth of files: mv -f * backup/summer-01 (moves all the files from the working directory to a subdirectory named /backup/summer-01).

The -b or --backup option makes a backup copy of the file or files you're moving and leaves the backup copy in the current directory. By default, the mv command renames the source files by appending a tilde (~); many file-listing utilities and programs can be configured to suppress the display of these files by default. In short, this option lets you move files to another directory while retaining copies that don't show up in file listings (unless you configure the listing command to display the backup files).

You can specify other backup file-naming options using the -V or --version-control option. If you specify -V numbered (or --version-control=numbered), the -b option adds a suffix (extension) that numbers the backup files.

The -u or --update option moves the file only when the source file is newer than the destination file. This option comes in handy when you want to avoid transferring a bunch of source files that are identical to the ones already present at the destination.