Skip to content
shellmap

rmDelete files and directories across all 5 shells

Equivalents in every shell

Bashunix
rm file
Zshunix
rm file
Fishunix
rm file
PowerShellwindows
Remove-Item file

Aliased as `rm`, `del`, `erase`, `rd`, `rmdir`, `ri`.

cmd.exewindows
del file

Use `rmdir /s /q dir` for directories.

Worked examples

Delete a directory and its contents

Bash
rm -rf dir
PowerShell
Remove-Item dir -Recurse -Force
cmd.exe
rmdir /s /q dir

Delete all files matching a glob

Bash
rm *.tmp
PowerShell
Remove-Item *.tmp
cmd.exe
del *.tmp

Prompt before deleting each file

Bash
rm -i file
PowerShell
Remove-Item file -Confirm
cmd.exe
del /p file

Gotchas

  • `rm -rf /` (Unix) and `Remove-Item C:\ -Recurse -Force` (PowerShell) are equally catastrophic — modern shells often refuse the literal root path, but typos can still nuke a subtree.
  • On Windows, `del` only deletes files; you need `rmdir` (or `Remove-Item -Recurse`) for directories.
  • Deleted items go to the Recycle Bin via Explorer, but command-line deletes are permanent on every shell here.

WSL & PowerShell Core notes

pwshThe `rm` alias for `Remove-Item` is removed in PowerShell Core on Linux/macOS — `/bin/rm` resolves first. On Windows pwsh, `rm` is still the alias. To avoid surprises in cross-platform scripts, use `Remove-Item` explicitly; flag semantics differ (`-Recurse -Force` vs `-rf`).
WSL`rm -rf /mnt/c/Some/Dir` deletes Windows files but cannot remove anything held open by a Windows process (Explorer preview, antivirus scanner). Close the holder on Windows first, or use `cmd.exe /c "rmdir /s /q ..."` for the Windows native path.

Common tasks using rm

Related commands