💻 Software
How to sort first directories then files etc… when using “ls” in Unix
Fresh5 days ago
Mar 15, 2026118050 viewsConfidence Score1%
1%
Problem
I would like to use the command to first show directories and then files. I tried: But I got a wrong order.
Error Output
ls -la | sort -k 1
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Canonical Fix
Unverified Fix
New Fix – Awaiting Verification
Fix for: How to sort first directories then files etc… when using “ls” in Unix
Low Risk
I do so love *nix and love seeing the inventiveness that goes into some of these replies... Mine's not nearly as fancy on GNU Linux : Given that I'm more comfortable with my linux CLI apps, I tend to also update coreutils on OSX :
Awaiting Verification
Be the first to verify this fix
Sign in to verify this fix