Doesn't the -h on du make the sizes in human readable formats? Seems that when I tried it, a folder with size 1.1 M showed up at the top of the list, when it should have shown up a the end of the list, as it was the biggest folder. It's better just to leave off -h. Makes reading the sizes a little harder, but the sorting is done correctly at least.
Thanks man. I didn't pay too close attention after I was like "hey, I can understand numbers like this better!". In the post I changed the "h" switch to a "k" for kilobytes. Not as nice as the human readable, but correct at least. ;-)
Actually, I was messing around with this on my laptop and found that -h is actually the default, so you have to use the m,k, or b option to get it to sort correctly. Personally, I just stick with b, so that I can see the actual size in bytes.
Doesn't the -h on du make the sizes in human readable formats? Seems that when I tried it, a folder with size 1.1 M showed up at the top of the list, when it should have shown up a the end of the list, as it was the biggest folder. It's better just to leave off -h. Makes reading the sizes a little harder, but the sorting is done correctly at least.
ReplyDeleteThanks man. I didn't pay too close attention after I was like "hey, I can understand numbers like this better!".
ReplyDeleteIn the post I changed the "h" switch to a "k" for kilobytes. Not as nice as the human readable, but correct at least. ;-)
Actually, I was messing around with this on my laptop and found that -h is actually the default, so you have to use the m,k, or b option to get it to sort correctly. Personally, I just stick with b, so that I can see the actual size in bytes.
ReplyDeleteSorry, forgot to add, the advantage of using -b, is that the command ends up as:
ReplyDeletedu -bs | sort -n
and it helps you find all the bs on your disk.