|
|
|
|
|
by useerup
1648 days ago
|
|
`ls | sort --time` is very close to `ls | sort LastWriteTime` which is how you would do it in PowerShell. In PowerShell `ls` is only used for retrieving the filesystem objects (files and directories). It does not have options for sorting or formatting[1] Sorting is generally handled by `sort` (alias for the Sort-Object cmdlet). Formatting is generally handled by one of the format commands, like format-table (alias `ft`) or format-list (alias `fl`) or by converting into another format like e.g. json or xml through `convertto-json`. I.e. if I want to display the full path of every file sorted by descending by last access, I would write: ls | sort -d LastAccessTime | select fullname
[1] except for the `-name` switch which is more of an optimization which only retrieves the local name as string objects. |
|
What really is the difference between `sort LastWriteTime` and `sort --LastWriteTime`? An argument without the dashes doesn't seem any fundamentally different from a flag.