How to make ls sort by file extension and then name?
Problem
By default the ls command sorts just by filename, but I want directories to appear before other file types. I might even want files to be sorted by extension, like the way Windows explorer sorts by the type column. Is there a way to do something similar with ls?
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Fix for: How to make ls sort by file extension and then name?
I think the complete answer is more of a combination of the above. (later ) has been supported on Linux since at least FC3 and will sort based on extension. was added more recently (maybe around FC8?). However, combining the two doesn't seem to work (at least on FC8). The primary issue seems to be with the use of singular primary sort keys. See this mailing list discussion for some insight into it.
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix