I sometimes wish human-readable
du -h option to be more fine-grained while still human-readable.
Instead of showing:
it would show something like:
14G 236M 788k 110b
Is there an easy / straightforward / standard way to get this?
Well, there seems to be no easy / straightforward / standard way to do this yet.
write a dedicated small converter utility in bash/awk/python/etc. so that:
$ echo "789456" | utility 770K 976o
Then pipe it to convert
du output. You can inspire from this related
question. If it runs well, it could also parse the output of any command piped to it like:
$ du -s | utility $ ls -la | utility
You can even alias it forever on you machine to:
duH() du -s $@ | utility
du --si). Any command output (
rsync) has to be parsed for finding digits strings meant to represent bytes and transformed without breaking the layout.
coreutils source code and add a new relevant option suiting your
needs. You'll probably have to have a glance at
./lib/human.c. Then once
modified, it'll be a matter of
make install so the
du on your machine will now have this option implemented.
Ccode and understand it first not to break it. You'll have to reinstall your own version of
coreutilson any machine you need to use it.
For now, I'm not getting into this soon. Anyway, feel free to post here your own pieces of solutions or alternatives workarounds as they come :)