1

I really don't like how Linux ls -al mixes files and directories.

Is it possible to list directories, then files, with single command?

dirA
dirB
dirC
fileA
fileB
fileC
0

1 Answer 1

11

As usual, man ls is your friend. If you're running Linux with the GNU coreutils, the --group-directories-first does precisely what you ask for.

4
  • That easy?? I remember it was some pretty complicated script few years back, so I didn't even bother. Maybe I confused it with something else, sorry. Thanks.
    – Danijel
    Mar 14, 2017 at 17:53
  • 1
    @Danijel well 10 years ago, the option didn't exist :) But it's been present for more than 5 years.
    – wazoox
    Mar 14, 2017 at 18:05
  • Well... maybe it was 10 years ago. Time flies... :-)
    – Danijel
    Mar 14, 2017 at 18:07
  • 1
    For those who didn't catch the subtlety, this will NOT work for ls on your mac, which will need those scripts. Mac is BSD and unix-like but not using GNU tool (I understand many expect these low-level tips to be portable, as they often are)
    – patcon
    Mar 24, 2021 at 18:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.