linux – Show DU outcome in purely megabytes

linux – Show DU outcome in purely megabytes

Its the -m option. So, for example:

$ du -s -m <my_directory_here>

UPDATE

Oh… you want an M printed after the number of megabytes. Here you are:

$ du -s -m /usr/local | sed s/^([0-9]*)(.*)$/1M 2/

or…

$ du -s -m /usr/local | sed s/^([0-9]*)(.*)$/1MiB 2/

or…

$ du -s -m /usr/local | sed s/^([0-9]*)(.*)$/1 MegaBytes 2/

etc.

UPDATE2

If you want fractions I would use du -k to print KiB and then:

$ du -s -k * | awk {printf %.3f MiB %sn, $1/1024, $2}
43.355 MiB bin
0.008 MiB etc
0.562 MiB include
5.836 MiB lib
0.008 MiB man
0.004 MiB mysql
2259.738 MiB mysql-5.5.27-osx10.6-x86_64
45.711 MiB share
340.641 MiB texlive

linux – Show DU outcome in purely megabytes

Leave a Reply

Your email address will not be published.