- Bash commands output strings while PS commands output objects!
The following standard aliases in PowerShell are used:
- dir -> Get-ChildItem
- sls -> Select-String
- cat -> Get-Content
- rm -> Remove-Item
- cp -> Copy-Item
- select -> Select-Object
- ? -> Where-Object
- % -> ForEach-Object
Bash
find 'dir' -type f -name '*.txt' -exec grep -n 'pattern' '{}' +
PowerShell
dir 'dir\*.txt' -Recurse | sls 'pattern'
Bash
find 'dir' -type f -name '*.txt' ! \( -exec grep -q 'pattern' '{}' \; \) -print
PowerShell
dir 'dir\*.txt' -Recurse | ?{ !(sls -Quiet -Path $_ -Pattern 'pattern') }
Bash
find 'dir' -name '*.txt' -delete
PowerShell
dir 'dir\*.txt' -Recurse | rm
Bash
head 'file'
tail 'file'
PowerShell
cat 'file' -Head 10
cat 'file' -Tail 10
Bash
... | head
... | tail
PowerShell
... | select -First 10
... | select -Last 10
Bash
type -a 'command'
PowerShell
Get-Command -all 'command'
Bash
<command write to stdout> | grep 'pattern'
PowerShell
<command write to stdout> | oss | sls 'pattern'