TIL: Sort human friendly values

Sorting numeric values in the input is easy. It just takes "sort -n". But what if the input contains human friendly units. For intance, "5G", "3M", "4K", etc. There is a flag to recognize and sort based on the human friendly units: "-h".

Incorrect: du -h | sort -nr
Correct: du -h | sort -rh

Caveat: "sort -h" works only on upper-case units. "K" will be treated as kilos, but "k" will not be!

Comments

Popular posts from this blog

The mysterious ORA-03111 error

Note on allocationSize parameter of @SequenceGenerator while using JPA

xVM's vboxmanage.exe command