mv
Files and directories
Usage
mv [source] [dest]Renames or moves; without -i or -n it overwrites the target silently.
Common flags
| Flag | Meaning |
|---|---|
| -i | Ask before overwriting the target |
| -n | Never overwrite; leave the target as it is |
| -f | Overwrite without asking (the default) |
| -v | Print each move |
Examples
mv notes.txt notes.mdRename in place.
mv *.jpg photos/Move every JPEG into photos.
mv -n a.txt backup/Moves unless backup/a.txt already exists.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does mv do?
Renames or moves; without -i or -n it overwrites the target silently.
Q. How do I type it?
mv [source] [dest] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
4 are listed here; the full set is in man mv. This command sits under Files and directories.
Related commands
man page: man mv