OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Useful Options And Examples

mv shares many of the same options as cp:

mv – Move And Rename Files


Table 4-6: mv Options


Option Meaning

Option Meaning

-i, --interactive Before overwriting an existing file, prompt the user for

confirmation. If this option is not specified, mv will silently overwrite files.


image

-u, --update When moving files from one directory to another, only

move files that either don't exist, or are newer than the existing corresponding files in the destination directory.


image

-v, --verbose Display informative messages as the move is

performed.


image


Table 4-7: mv Examples


Command Results

Command Results

mv file1 file2 Move file1 to file2. If file2 exists, it is overwritten

with the contents of file1. If file2 does not exist, it is created. In either case, file1 ceases to exist.


image

mv -i file1 file2 Same as above, except that if file2 exists, the user is

prompted before it is overwritten.


image

mv file1 file2 dir1 Move file1 and file2 into directory dir1. dir1 must

already exist.


image

mv dir1 dir2 If directory dir2 does not exist, create directory dir2 and move the contents of directory dir1 into dir2 and delete directory dir1.

If directory dir2 does exist, move directory dir1

(and its contents) into directory dir2.


image


Top OS Cloud Computing at OnWorks: