Skip to content

From Bash to PowerShell

Mapping bash commands to their pwsh cmdlet equivalents.

bash command pwsh cmdlet pwsh aliases
grep Select-String
Select-String -Pattern "text" -Path "file"
sls
ls Get-ChildItem
Get-ChildItem -Path "directory"
gci, dir, ls
cd Set-Location
Set-Location -Path "directory"
sl, cd, chdir
pwd Get-Location
Get-Location
gl, pwd
cp Copy-Item
Copy-Item -Path "source" -Destination "dest"
copy, cp, cpi
mv Move-Item
Move-Item -Path "source" -Destination "dest"
move, mv, mi
rm Remove-Item
Remove-Item -Path "file"
del, erase, rd, ri, rm, rmdir
mkdir New-Item
New-Item -Path "dir" -ItemType Directory
ni, md
cat Get-Content
Get-Content -Path "file"
gc, type, cat
echo Write-Output
Write-Output "text"
echo, write
find Get-ChildItem (with recursion)
Get-ChildItem -Path "dir" -Recurse
gci -r
head Get-Content (with limit)
Get-Content -Path "file" -TotalCount 10
gc -head
tail Get-Content (with tail)
Get-Content -Path "file" -Tail 10
gc -tail
touch New-Item
New-Item -Path "file" -ItemType File
ni
wc Measure-Object
Get-Content "file" \| Measure-Object -Word/-Line/-Character
measure
chmod Set-Acl or icacls
Set-Acl -Path "file" -AclObject $acl
None
chown Set-Acl
Set-Acl -Path "file" -AclObject $acl
None
ps Get-Process
Get-Process
gps, ps
kill Stop-Process
Stop-Process -Id pid or -Name name
spps, kill
man Get-Help
Get-Help cmdlet-name -Full
help
history Get-History
Get-History
h, history
df Get-PSDrive
Get-PSDrive
gdr
du Measure-Object on folder size
Get-ChildItem -Recurse \| Measure-Object -Property Length -Sum
None
wget Invoke-WebRequest
Invoke-WebRequest -Uri "url" -OutFile "file"
iwr, curl, wget
sort Sort-Object
command \| Sort-Object -Property Property
sort
uniq Get-Unique or Select-Object -Unique
command \| Sort-Object \| Get-Unique
gu
which Get-Command
Get-Command commandname
gcm
uniq Get-Unique or Select-Object -Unique
command
gu
count Measure-Command or Measure-Object
command
measure