3 ms·
You have to learn a few things, just like you have to learn them on Unix. You need to familiarize yourself with some basic cmdlets like Get-ChildItem or Format-
by TeMPOraL 11y ago
You have to learn a few things, just like you have to learn them on Unix. You need to familiarize yourself with some basic cmdlets like Get-ChildItem or Format-Table or Sort-Object, etc. Just like you need to learn about ls or grep or the test syntax under Unix.
PowerShell is pretty discoverable though (not as discoverable as one may be used to in Lisp ecosystem, but still). For instance, I can fetch the list of properties like the one I pasted in my previous comment by using: Get-ChildItem somefile | Get-Member. It's roughly equivalent to ls filename | <something that would describe the file's properties if the result wasn't plaintext>.
Personally, I do find cmdlets a bit cumbersome to type in even with TAB-completion, but fortunately PowerShell defines a lot of aliases - like (again, I'm just copying what I found after typing "alias"):
CommandType Name
----------- ----
(...)
Alias cat -> Get-Content
Alias cd -> Set-Location
Alias chdir -> Set-Location
Alias clear -> Clear-Host
Alias cp -> Copy-Item
Alias diff -> Compare-Object
Alias dnsn -> Disconnect-PSSession
Alias echo -> Write-Output
Alias kill -> Stop-Process
Alias ls -> Get-ChildItem
Alias man -> help
Alias mount -> New-PSDrive
Alias pushd -> Push-Location
Alias pwd -> Get-Location
Alias rm -> Remove-Item
Alias tee -> Tee-Object
(...)
So e.g. ls | Get-Member works too.
The cmdlets however are often more powerful than their bash/Unix equivalent and - again - they work with objects, which you can always inspect if you're not sure what properties and methods they expose.