mv — Move or rename files and directories across all 5 shells
Equivalents in every shell
Worked examples
Rename a file
Bash
mv old.txt new.txtPowerShell
Rename-Item old.txt new.txtcmd.exe
ren old.txt new.txtMove multiple files into a directory
Bash
mv *.log logs/PowerShell
Move-Item *.log logs/cmd.exe
move *.log logs\Move without overwriting existing files
Bash
mv -n source destPowerShell
Move-Item source dest -ErrorAction StopGotchas
- On Unix, `mv` across filesystems copies + deletes; on the same fs it is an atomic rename.
- cmd `move` cannot rename and move simultaneously across drives; use `move` then `ren`.
- PowerShell `Move-Item` with wildcards requires the destination to be a directory.
WSL & PowerShell Core notes
pwshThe `mv` alias for `Move-Item` is removed in PowerShell Core on Linux/macOS — `/bin/mv` resolves first. Windows pwsh keeps the alias. Cross-platform scripts should call `Move-Item` directly.
WSLRenaming inside `/mnt/c/...` writes through DrvFs and is not atomic relative to other Windows processes; an Explorer file handle on the target will block the rename with EBUSY. For atomic renames stay on the Linux side, then `cp` the final file to `/mnt/c`.
Common tasks using mv
- Discard uncommitted changes in a git repo
Throw away local edits and reset the working tree to the last commit — the "I messed up, start over" gesture. Three subtly-different idioms (`git restore`, `git checkout --`, `git reset --hard`) cover three different scopes; picking the wrong one either keeps junk or nukes work you wanted to keep.
- Rename multiple files at once
Apply a rename rule (extension swap, prefix add, regex replace) to a batch of files in one shell-native pass — no GUI, no third-party tool.