mv
What is mv?
mv: Move / Rename — Move a file or rename it. mv moves or renames files and folders. mv old.txt new.txt renames a file, and mv report.pdf archive/ moves it into another folder. Within the same disk, moving is instant, because only the file's directory entry changes. Across disks, mv copies the data and then deletes the original.
Frequently asked questions about mv
What should you keep in mind with mv?
By default it overwrites an existing file at the destination without asking. mv -i asks first, and mv -n never overwrites. A useful trick for safe deploys is writing a new file under a temporary name and then using mv to replace the old one. On the same file system the replacement is atomic, so nothing ever reads a half-written file. In Git projects, git mv records the move so history follows the file.
At a glance
| Category | CLI commands |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |