On 11/11/06, Paul Reilly <paulr at maths.tcd.ie> wrote:
> Anyone know a simple way to make df display it's output nicely?
Sure. This fact that I call df twice is slightly garbage, but it gets
the job done and I cannot think of another way to not sort the first
line, short of using a tmp file.
:jmglov at laurana; df -h | head -1; df -h | sed -e 1d | sort
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 123M 116M 6.6M 95% /
/dev/hda5 1.9G 710M 1.1G 39% /tmp
/dev/hda6 9.4G 5.1G 4.3G 54% /usr
/dev/hda7 484M 219M 266M 46% /var
/dev/hda8 16G 14G 2.2G 87% /home
none 252M 0 252M 0% /dev/shm
udev 252M 600K 252M 1% /dev
> I suppose you could do this by recompiling, or wrapping 'df' in some
> script to format it nicely. But there must be a better way.
Wrapping df in a script, or better yet piping its output to another
program or programs is The Unix Way. Kitchen-sink options-having
programs like GNU ls(1) are not The Unix Way. :)
-Josh
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!