cp — Copy files and directories across all 5 shells
Equivalents in every shell
Worked examples
Copy a directory recursively
Bash
cp -r src dstPowerShell
Copy-Item src dst -Recursecmd.exe
xcopy src dst /e /iCopy preserving timestamps and attributes
Bash
cp -p file destPowerShell
Copy-Item file destcmd.exe
xcopy file dest /kMirror a directory (delete extras at dest)
Bash
rsync -a --delete src/ dst/PowerShell
robocopy src dst /MIRcmd.exe
robocopy src dst /MIRGotchas
- PowerShell `cp` is `Copy-Item`, not Unix `cp` — flag syntax differs (`-Recurse`, not `-r`).
- `xcopy` is deprecated in favor of `robocopy` on modern Windows; robocopy has saner defaults and exit codes.
- Trailing slash on source path matters in `rsync` and Unix `cp -r`; on Windows tools it does not.
WSL & PowerShell Core notes
pwshOn Linux/macOS PowerShell Core, the `cp` alias for `Copy-Item` is removed and `/bin/cp` wins. On Windows pwsh the alias is intact. Use `Copy-Item` explicitly in scripts that target both platforms.
WSLCopying across the WSL ↔ Windows boundary (`/mnt/c/...`) goes through the DrvFs adapter and is roughly an order of magnitude slower than copying within the Linux filesystem (`~`). Keep build artifacts under `~` and only push final outputs to `/mnt/c` if you must.