FG
💻 Software

Sorting human readable file sizes

Fresh5 days ago
Mar 15, 202620061 views
Confidence Score0%
0%

Problem

How can I sort a list using a human-readable file-size sort, numerical sort that takes size identifier (G,M,K) into account? Can I sort " " output for example? Problem: Consider the problem of listing files/folders and sorting them by their size. You can achieve that by running: This lists the file…

Error Output

du -s * | sort -n

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Sorting human readable file sizes

Low Risk

Use GNU coreutils >= 7.5: du -hs * | sort -h (Taken from this serverfault question) Man page Edit: You can check your versions using and if you are using the GNU versions. If you're using homebrew you may need to use and .

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment