commands
mv — move or rename files
Moves an entry or renames it. Existing directory destinations normally receive the source basename. Across filesystems a move can copy then remove the source, so atomic rename is not guaranteed. Examples assume a fresh chapter files lab.
Formal Syntax & Structure
linux syntaxlinux
mv [OPTION]... SOURCE DESTParameters & Attributes
| Name | Type | Description |
|---|---|---|
| -i | option | Prompt before overwrite |
| -n | option | Skip existing destinations; status behavior depends on version |
| SOURCE | operand | Object to move |
| DEST | operand | Destination path |
Return Value
filesystem change and exit status
GNU mv returns 0 on success and nonzero on failure. Declining an interactive overwrite returned 1 and preserved both source and destination in the tested GNU version; verify both paths, particularly after a cross-filesystem move.
Working Example
Example Snippetlinux
mv -i notes/hello.txt archive/saved.txt