remove-item — PowerShell's delete cmdlet — the rm / rmdir / del equivalent across all 5 shells
Equivalents in every shell
rm file.txtDeletes a file. `rm -r dir/` deletes a directory recursively; `rm -rf dir/` skips per-file confirmation (also masks errors from missing paths). `rm` has NO confirmation by default — there is no trash / undo unless you alias to `rm -i` or install `trash-cli`.
rm file.txtSame external. On macOS, files removed by `rm` do NOT go to the Finder Trash — they are unlinked immediately and unrecoverable without backups. Use Finder's `Move to Trash` or `brew install trash` for recoverable deletes.
rm file.txtSame external. Fish does NOT ship `rm -i` aliasing by default — accidental `rm dir/*` is just as destructive as in bash. For undo-able deletes install `trash-cli` and either alias `rm` to `trash` or use `trash` directly in muscle memory.
Remove-Item file.txtPowerShell-native cmdlet (aliases `rm`, `del`, `erase`, `ri`, `rd`, `rmdir`). For directories add `-Recurse -Force` — without `-Recurse` PowerShell PROMPTS before a recursive delete (different from Unix `rm` which silently refuses). `-LiteralPath` treats `[ ] *` as literal characters (PowerShell's wildcards otherwise interpret them).
del file.txtBuilt-in. `del` removes files only; `rmdir` (alias `rd`) removes directories with `rmdir /s /q dir` for recursive force. cmd splits files vs dirs across two binaries; PowerShell's `Remove-Item` unifies them under one cmdlet with `-Recurse` doing the dir-tree walk.
Worked examples
Delete a file
rm file.txtRemove-Item file.txtdel file.txtDelete a directory recursively without prompts
rm -rf dir/Remove-Item -Recurse -Force dir/rmdir /s /q dirDelete all .log files older than 7 days
find . -name '*.log' -mtime +7 -deleteGet-ChildItem *.log | Where-Object LastWriteTime -lt (Get-Date).AddDays(-7) | Remove-Itemforfiles /m *.log /d -7 /c "cmd /c del @file"Gotchas
- `Remove-Item -Recurse -Force` STILL prompts for some protected paths — `C:\Windows\Installer`, OneDrive-synced folders, and items with the ReadOnly attribute may need `-Confirm:$false` AND `-Force` together. Wrap destructive scripts in `$ConfirmPreference = 'None'` only after dry-running the same command with `-WhatIf`.
- PowerShell `Remove-Item *` skips HIDDEN files by default — the OPPOSITE of Unix `rm -rf *` which removes hidden ones too. To match Unix semantics use `Remove-Item * -Force` (and `-Recurse` for dirs) OR `Get-ChildItem -Force | Remove-Item` to enumerate everything. This is the single biggest cleanup-script footgun for Unix transplants moving to PowerShell.
- `-LiteralPath` is essential for paths containing `[ ] *` (PowerShell wildcards). `Remove-Item 'C:\My [Old] Folder'` SILENTLY DELETES NOTHING because the wildcard parser sees `[Old]` as a character class with no match — use `Remove-Item -LiteralPath 'C:\My [Old] Folder'`. Paths from `Get-ChildItem` arrive as objects that handle this automatically; literal strings do not.
- PowerShell aliases `rm` to `Remove-Item`, but on pwsh Linux/macOS the alias is REMOVED so the real `/bin/rm` resolves. Scripts must spell `Remove-Item` (or use the cmdlet's actual flags) to behave identically on both platforms — `rm -rf` on Windows pwsh calls the cmdlet which doesn't understand `-rf` and errors out.
- `Remove-Item` does NOT send files to the Recycle Bin — items are permanently unlinked. To send to Recycle Bin from PowerShell use `Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile($path, 'OnlyErrorDialogs', 'SendToRecycleBin')` after `Add-Type -AssemblyName Microsoft.VisualBasic`, or install the `Recycle` module from the PowerShell Gallery.