How do I sort by human readable sizes numerically?

Posted by UAdapter on Ask Ubuntu See other posts from Ask Ubuntu or by UAdapter
Published on 2011-11-17T17:02:59Z Indexed on 2011/11/18 18:04 UTC
Read the original article Hit count: 315

Filed under:
|

for example I have command that shows how much space folder takes

du folder | sort -n

it works great, however I would like to have human readable form

du -h folder

however if I do that than I cannot sort it as numeric.

How to join du folder and du -h folder to see output sorted as du folder, but with first column from du -h folder

P.S. this is just an example. this technique might be very useful for me (if its possible)

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about sort