0
0
PowerShellscripting~5 mins

PowerShell vs Bash vs CMD comparison

Choose your learning style9 modes available
Introduction
You want to know the differences between PowerShell, Bash, and CMD so you can pick the right tool for your tasks.
You need to automate tasks on Windows computers.
You want to write scripts that work on Linux or macOS.
You want to run simple commands quickly on Windows.
You want to manage system settings or files with powerful commands.
You want to understand which shell fits your daily work best.
Syntax
PowerShell
PowerShell: Uses cmdlets like Get-Process
Bash: Uses commands like ls, grep
CMD: Uses commands like dir, copy
PowerShell uses objects, not just text, which makes it powerful.
Bash is common on Linux and macOS, CMD is older and Windows-only.
Examples
Lists processes using more than 100 CPU seconds.
PowerShell
PowerShell:
Get-Process | Where-Object {$_.CPU -gt 100}
Shows processes related to Firefox.
PowerShell
Bash:
ps aux | grep firefox
Finds Firefox processes in the task list.
PowerShell
CMD:
tasklist | findstr firefox
Sample Program
This script shows how to list files in each shell. PowerShell uses Get-ChildItem, Bash uses ls, CMD uses dir.
PowerShell
Write-Output "PowerShell: List files"
Get-ChildItem

Write-Output "Bash: List files"
# bash command: ls -l

Write-Output "CMD: List files"
# cmd command: dir
OutputSuccess
Important Notes
PowerShell works well on Windows and now also on Linux and macOS.
Bash is great for Linux/macOS but can be installed on Windows too.
CMD is simple but less powerful than PowerShell or Bash.
Summary
PowerShell is object-based and powerful for Windows automation.
Bash is text-based and common on Linux/macOS for scripting.
CMD is basic and mostly used for simple Windows commands.