From Bash to PowerShell
Mapping bash
commands to their pwsh
cmdlet equivalents.
bash command |
pwsh cmdlet |
pwsh aliases |
---|---|---|
grep |
Select-StringSelect-String -Pattern "text" -Path "file" |
sls |
ls |
Get-ChildItemGet-ChildItem -Path "directory" |
gci , dir , ls |
cd |
Set-LocationSet-Location -Path "directory" |
sl , cd , chdir |
pwd |
Get-LocationGet-Location |
gl , pwd |
cp |
Copy-ItemCopy-Item -Path "source" -Destination "dest" |
copy , cp , cpi |
mv |
Move-ItemMove-Item -Path "source" -Destination "dest" |
move , mv , mi |
rm |
Remove-ItemRemove-Item -Path "file" |
del , erase , rd , ri , rm , rmdir |
mkdir |
New-ItemNew-Item -Path "dir" -ItemType Directory |
ni , md |
cat |
Get-ContentGet-Content -Path "file" |
gc , type , cat |
echo |
Write-OutputWrite-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-ItemNew-Item -Path "file" -ItemType File |
ni |
wc |
Measure-ObjectGet-Content "file" \| Measure-Object -Word/-Line/-Character |
measure |
chmod |
Set-Acl or icaclsSet-Acl -Path "file" -AclObject $acl |
None |
chown |
Set-AclSet-Acl -Path "file" -AclObject $acl |
None |
ps |
Get-ProcessGet-Process |
gps , ps |
kill |
Stop-ProcessStop-Process -Id pid or -Name name |
spps , kill |
man |
Get-HelpGet-Help cmdlet-name -Full |
help |
history |
Get-HistoryGet-History |
h , history |
df |
Get-PSDriveGet-PSDrive |
gdr |
du |
Measure-Object on folder sizeGet-ChildItem -Recurse \| Measure-Object -Property Length -Sum |
None |
wget |
Invoke-WebRequestInvoke-WebRequest -Uri "url" -OutFile "file" |
iwr , curl , wget |
sort |
Sort-Objectcommand \| Sort-Object -Property Property |
sort |
uniq |
Get-Unique or Select-Object -Uniquecommand \| Sort-Object \| Get-Unique |
gu |
which |
Get-CommandGet-Command commandname |
gcm |
uniq |
Get-Unique or Select-Object -Uniquecommand |
gu |
count |
Measure-Command or Measure-Objectcommand |
measure |