Bash <-> PowerShell Translator
Translate Bash one-liners to PowerShell and vice versa using a rules table.
Paste a one-liner to translate.
Rules reference
| Bash | PowerShell |
|---|---|
| ls | Get-ChildItem |
| ls -la | Get-ChildItem -Force |
| cat | Get-Content |
| grep | Select-String |
| find . -name *.cs | Get-ChildItem -Recurse -Filter *.cs |
| rm -rf path | Remove-Item -Recurse -Force path |
| cp src dst | Copy-Item src dst |
| mv src dst | Move-Item src dst |
| mkdir -p a/b | New-Item -ItemType Directory -Force a/b |
| touch f | New-Item -ItemType File f |
| head -n 5 | Select-Object -First 5 |
| tail -n 5 | Select-Object -Last 5 |
| echo hi | Write-Output hi |
| export VAR=x | $env:VAR = 'x' |
| $VAR | $env:VAR |
| cmd > out | cmd > out |
| cmd >> out | cmd >> out |
| cmd 2>&1 | cmd 2>&1 |
| a && b | a; if ($?) { b } (PS 5.1) |
| a || b | a; if (-not $?) { b } (PS 5.1) |
| $(cmd) | $(cmd) |
About this tool
Paste a one-liner in either Bash or PowerShell and convert it to the other shell. Covers ls/Get-ChildItem, cat/Get-Content, grep/Select-String, find/Get-ChildItem -Recurse, rm/Remove-Item, env vars, head/tail, redirections and &&/|| chaining (note: PS 5.1 has no native &&/||).