How can I display the files in a unix directory sorted by their human readable size, going from largest to smallest?
du -h | sort -V -k 1
but it does not seem to work.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
ls -S wasn't an option on the OS for me. The following worked:
ls -l | sort -k 5nr
They "key" was to specify the column to sort (get it, the "key"). Above I'm specifying
-k 5nr meaning sort on 5th column which is size (5) evaluated as a number (n) in descending order (n)
Reference sort documentation for more information