5

How can I use du -h to sort the displayed files and directories in ascending order of size?

kos
  • 41,268
D-T
  • 506

1 Answers1

11

You can pipe | the output of du's -h, --human-readable to sort's -h, --human-numeric-sort for human format numerical based sorting like:

du -h | sort -h

... and descending by adding sort's -r, --reverse like:

du -h | sort -rh
Raffa
  • 34,963