HxHippy

mv

Move or rename files and directories

Overview

Moves files or directories from one place to another, or renames them.

Syntax

mv [OPTION]... SOURCE DEST

Common Options

-i, --interactive

Prompt before overwriting an existing file.

-f, --force

Do not prompt before overwriting (suppresses -i).

-n, --no-clobber

Do not overwrite an existing file if it already exists.

-v, --verbose

Explain what is being done.

-u, --update

Move only when the source file is newer than the destination file or when the destination file is missing.

Examples

$ mv oldfile.txt newfile.txt

Renames oldfile.txt to newfile.txt.

$ mv myfile.txt /tmp/

Moves myfile.txt to the /tmp/ directory.

$ mv -i source.txt target_dir/

Moves source.txt to target_dir/, prompting if a file with the same name exists.

$ mv my_directory/ another_location/

Moves my_directory into another_location/.

$ mv file1.txt file2.txt some_directory/

Moves file1.txt and file2.txt into some_directory/.

moverenamefilesdirectorymv