This CMD vs PowerShell vs Bash table shows the same task in Windows Command Prompt, PowerShell and bash on one row: listing and copying files, finding text in files (the PowerShell equivalent of grep is Select-String), environment variables, processes, networking, services, reading and writing file contents, and scripting with variables, conditionals, loops and functions. Search with a command from any of the three shells and you get its counterparts, each with a copy button.
The sheet also covers what usually goes wrong when you move between them: PowerShell aliases that look like Unix commands but are not (curl and wget in Windows PowerShell 5.1, ls and rm everywhere on Windows), different quoting and escape characters, the execution policy error that blocks .ps1 scripts, and the differences between Windows PowerShell 5.1 and PowerShell 7. PowerShell commands work in both versions unless a note says otherwise; where a CMD equivalent does not exist, the table says so rather than inventing one.
How to use
- Search for the command you know, in any shell (for example “grep”, “findstr” or “Select-String”), or for the task (“kill process”, “environment variable”).
- Read across the row for the equivalent in the other two shells and click Copy next to the one you need.
- Check the note under the task name: it flags version differences (PowerShell 5.1 vs 7) and Windows-only cmdlets.
- Scroll to the alias, quoting and execution policy sections if a command behaves differently from what you expected.
- Use Print / Save as PDF for a desk copy; the page also works on a phone, where each row becomes a card.
Frequently asked questions
What is the PowerShell equivalent of grep?
Select-String. Search a file with Select-String -Path app.log -Pattern error, or filter command output with ipconfig | Select-String IPv4. It is case-insensitive by default (add -CaseSensitive), uses .NET regular expressions, and -NotMatch is the equivalent of grep -v. For recursive searches pipe Get-ChildItem -Recurse -Filter *.log into Select-String. Its short alias is sls.
Why does curl behave strangely in PowerShell?
In Windows PowerShell 5.1, curl and wget are aliases for Invoke-WebRequest, so curl flags like -X, -H and -d are rejected or mean something else. Type curl.exe to run the real curl that ships with Windows 10 1803 and later. PowerShell 7 removed those aliases, so curl runs curl.exe there. On Linux and macOS, curl was never an alias.
Is PowerShell better than CMD?
For anything beyond running a program or a short batch file, yes. PowerShell pipes structured objects instead of text, so you filter and sort by property name (Where-Object, Sort-Object) instead of parsing columns, and it has real functions, error handling, JSON and CSV support and remoting. CMD is still fine for legacy .bat files and some installers, and every CMD tool (ipconfig, robocopy, netstat) can be run from PowerShell as well.
How do I fix “running scripts is disabled on this system”?
That is the execution policy, which is Restricted by default on Windows 10 and 11 client editions. Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell (no admin needed). Your own scripts then run, and scripts downloaded from the internet must be signed or unblocked with Unblock-File. Get-ExecutionPolicy -List shows what is set where; a Group Policy setting overrides anything you set yourself.
Can I run bash commands on Windows?
Yes, with Windows Subsystem for Linux. Run wsl --install from an elevated prompt (Windows 10 version 2004 or later, or Windows 11) to install Ubuntu, then open it from the Start menu or run single commands from CMD or PowerShell with wsl followed by the command, such as wsl grep -rn TODO. Git for Windows also includes Git Bash, a lighter bash with the common Unix tools.
What is the difference between Windows PowerShell and PowerShell 7?
Windows PowerShell 5.1 (powershell.exe) is built into Windows and only receives fixes. PowerShell 7 (pwsh) is the current, cross-platform version that runs on Windows, Linux and macOS and is installed separately; both can be installed together. Version 7 adds && and || between commands, the ternary and ?? operators, writes UTF-8 files by default and drops some confusing aliases such as curl and wget.
Objects vs text: the one idea that makes PowerShell click
In CMD and bash a pipe carries text. To get the process using the most memory in bash you pick the right column out of ps output with sort -k or awk, and the command breaks if the column layout changes. In PowerShell the pipe carries objects with named properties, so the same job is Get-Process | Sort-Object WS -Descending | Select-Object -First 1. Nothing is parsed, and the property names are the same on every machine.
The practical consequence is a different discovery workflow. In bash you read a man page to learn the output format; in PowerShell you pipe any command into Get-Member to see which properties and methods its objects have, then filter with Where-Object and choose fields with Select-Object. Only when the output reaches the screen or a file does PowerShell turn it into text.
Native programs like ipconfig, git or curl.exe still output text in PowerShell, so Select-String and -match work on them the way grep would. Their exit code is in $LASTEXITCODE, not $?.
Translating a script between the three shells
Line-by-line translation works for simple scripts, but a few differences catch almost everyone:
• Comparison operators: CMD uses == for strings and EQU, GTR, LSS for numbers; PowerShell uses -eq, -gt, -lt, -like and -match (a bare > is redirection); bash uses = inside [ ] for strings and -gt or (( )) for numbers.
• Variables: %name% in CMD (and !name! inside loops after setlocal EnableDelayedExpansion), $name in PowerShell, $name in bash with no spaces around = when assigning.
• Loops in .bat files double the percent sign: for %%f in (*.txt) inside a file, for %f at the prompt.
• Paths: PowerShell accepts both / and \ on Windows; bash on Linux needs /. Environment variables are case-insensitive on Windows and case-sensitive on Linux.
• Errors: CMD continues after a failure unless you check %ERRORLEVEL%; bash continues unless set -e; PowerShell continues after non-terminating errors unless $ErrorActionPreference = 'Stop'.
When a script needs to run on Windows and Linux, PowerShell 7 or bash under WSL avoids keeping two copies.
