mv


mv

Purpose

Rename files and directories or move them from one directory to another.

Syntax

mv [options] source destination

Options

-b makes backup copies of files being moved or renamed.

-f removes existing files without prompting.

-i prompts before overwriting any existing files.

-v displays the name of the file before moving it.

Description

The mv command either renames a file or moves it to another directory. The command works on either plain files or directories. Thus, you can rename the file sample to sample.old with the command mv sample sample.old. On the other hand, you can move the file /tmp/sample to /usr/local/sample with the command mv /tmp/sample /usr/local/sample.