Sorting du -h accounting for decimals

89 Views Asked by At

I have done du -h /path, which gives me a line with the following syntax:

size path
size path
size path

I want to sort the lines of the file based on size. The problem is that size can contain decimal values, like 9.4G. If I apply sort -hr it gives me a weird sorting like:

444G    path
326G    path
9.4G    path
9.4G    path
8.3G    path
8.2G    path
7.8G    path
74G     path
7.4G    path
7.3G    path

So I guess the problem is that the decimals are being, ignored? I think 74G appears below 7.8G because sort is interpreting it as 78G. How can I solve this problem? (it looks like it has something to do with locales).

NOTE: I use git-bash.

0

There are 0 best solutions below