Name

mv

Synopsis

    mv [options]sources target

Basic command to move files and directories around on the system or to rename them. mv works as the following table shows.

Source

Target

Result

File

name

Rename file as name.

File

Existing file

Overwrite existing file with source file.

Directory

name

Rename directory as name.

Directory

Existing directory

Move directory to be a subdirectory of existing directory.

One or more files

Existing directory

Move files to directory.

Common Options

--

Use this when one of the names begins with a -. For compatibility with old programs, a plain - also works.

-f, --force

Force the move, even if target file exists; suppress messages about restricted access modes.

-i, --interactive

Inquire; prompt for a y (yes) response before overwriting an existing target.

GNU/Linux Options

-b, --backup[=control]

Back up any existing files. When using the long version of the option, the optional control parameter controls the kind of backup. When no control is specified, mv attempts to read the control value from the VERSION_CONTROL environment variable. Accepted values are:

none, off

Never make backups.

numbered, t

Make numbered backups.

existing, nil

Match existing backups, numbered or simple.

simple, never

Always make simple backups.

--reply= type

Set the default behavior that is used for overwriting existing files. --replay=yes is the same as --force. --replay=query is the same as --interactive. --replay=no skips existing files.

--strip-trailing-slashes ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.