As I see it ls does one job (list directory contents) and does it well (by supporting 37 flags).
If ls was a human, we would call him an expert.
Since unix tools expect input as plain text, the flags that ls supports are absolutely useful and I believe this is obvious to anyone who has written more than 50 lines of bash.
When your input doesn't support a standard complex structure (e.g json with some standard set fields), claiming that “sort by creation time” is a simple filter is funny.
First you would need a ls flag so that ls will output creation times in an easy to process time format (seconds since epoch), then you would need to ask sort to work on a certain (1 flag) numerical (1 more flag) field. Last you would have to pass sort's output to a stream processor to get rid of unwanted fields.
The same in PowerShell - using ls without the abundance of parameters - would look like:
ls | sort -des LastWriteTime | select name
1: Get the "child" items of the current directory
2: sort them descending according to the last write time
3: strip out all other properties but name
No need for ls to support a plethora of formatting options. And the typing is actually pretty short due to tab completion:
ls | sort -des *time<tab><tab><tab><tab><tab> | select n<tab>
I could not remember what the "last change time" was called, so I just entered *time and used tab completion. PowerShell is smart enough to be aware that (one of) the output types from "ls" has a property called "LastWriteTime" - it came up after 5 tabs. Similarly when pressing n<tab> in the select it completed directly to Name because it knew (still from the pipeline) that output of "ls" would have a "Name" property - even if sorted first.
I totally agree that trying to filter the output of ls is madness when compared to using the built-in flags. But doesn't this also indicate that command output should be more unified in it's output format? "cut", for example, is a useful tool, but it seems ham-fisted as a way of formatting output data for anything other than a one-time job.
If ls was a human, we would call him an expert.
Since unix tools expect input as plain text, the flags that ls supports are absolutely useful and I believe this is obvious to anyone who has written more than 50 lines of bash. When your input doesn't support a standard complex structure (e.g json with some standard set fields), claiming that “sort by creation time” is a simple filter is funny.
First you would need a ls flag so that ls will output creation times in an easy to process time format (seconds since epoch), then you would need to ask sort to work on a certain (1 flag) numerical (1 more flag) field. Last you would have to pass sort's output to a stream processor to get rid of unwanted fields.
Current “list files by creation time”:
Replace sort flag with filters: