The mv command

The mv command moves files or directories to a new directory, or renames them in their existing one:

$ mv file path/to/directory
$ mv file1 file2

If the last argument is a directory, all of the arguments before it are moved into it, allowing you to move several files at once:

$ mv file1 file2 dir1 path/to/directory

Note that mv overwrites any existing file at its destination, by design. When you're using this interactively, if you don't expect to be overwriting files, the -i switch can be used to prompt you before you overwrite a file:

$ ls
customers-new  customers
$ mv -i customers-new customers
mv: overwrite 'customers'?

If you enter y at this prompt and press Enter, the overwrite will proceed. This feature is designed for ...

Get Bash Quick Start Guide 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.