Interesting examples, especially in light of the recent debates about Unix shells and PowerShell.
In PowerShell, the `ls` command is a simple command that produces output without flags to control output format, ordering or filtering. Like with higher order functional programming, those tasks are delegated to cmdlets like Format-List, Format-Table, Select-Object, Where-Object.
Some PowerShell examples:
To list the files and directories (children) of a directory:
ls
To get just the names or the full path:
ls | select Name
ls | select FullName
To discover
which properties are available from `ls`:
ls | gm
To select only files larger than 200MB:
ls | ? Length -gt 200MB
(ls is alias for Get-ChildItem, gm is alias for Get-Member, ? is alias for Where-Object)
It is somewhat ironic that PowerShell is more true to the principle of "do one thing and do it well" than the Unix shells.
In PowerShell, the `ls` command is a simple command that produces output without flags to control output format, ordering or filtering. Like with higher order functional programming, those tasks are delegated to cmdlets like Format-List, Format-Table, Select-Object, Where-Object.
Some PowerShell examples:
To list the files and directories (children) of a directory:
To get just the names or the full path: To discover which properties are available from `ls`: To select only files larger than 200MB: (ls is alias for Get-ChildItem, gm is alias for Get-Member, ? is alias for Where-Object)It is somewhat ironic that PowerShell is more true to the principle of "do one thing and do it well" than the Unix shells.