a question regarding proper printf(3) formating and alignment
Dan Nelson
dnelson at allantgroup.com
Wed Nov 17 22:41:42 UTC 2010
In the last episode (Nov 17), Karl Vogel said:
> >> In the last episode (Nov 17), Alexander Best said:
>
> A> i've looked at a lot of utilities in the bsd src tree and most of them
> A> seem to be doing something like this:
>
> A> Device 1M-blocks Used Avail Capacity
> A> /dev/label/swapfs 10239 0 10239 0%
> A> /dev/label/swap 8191 0 8191 0%
> A> Total 18431 0 18431 0%
>
> A> i'd like to learn of ways formatting the header so that it aligns
> A> properly, whether the device name is 10 chars long or 1000.
>
> ports/textproc/align is a nifty perl script that'll do this for just
> about any type of column-based input. If you just want to fix "df" and
> you know how long the longest device name is, try something like this:
Bad example, since df also auto-sizes its columns :)
I think /usr/bin/rs can do column auto-balancing, but every time I try to
make it do what I want, I fail.
--
Dan Nelson
dnelson at allantgroup.com
More information about the freebsd-questions
mailing list