From owner-freebsd-questions@FreeBSD.ORG Wed Nov 17 22:41:42 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B9D610656A3 for ; Wed, 17 Nov 2010 22:41:42 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from email2.allantgroup.com (email2.emsphone.com [199.67.51.116]) by mx1.freebsd.org (Postfix) with ESMTP id F2ABC8FC1E for ; Wed, 17 Nov 2010 22:41:41 +0000 (UTC) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by email2.allantgroup.com (8.14.4/8.14.4) with ESMTP id oAHMfcPI085782 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 17 Nov 2010 16:41:38 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.4/8.14.4) with ESMTP id oAHMfcTY084757 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 17 Nov 2010 16:41:38 -0600 (CST) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.4/8.14.4/Submit) id oAHMfbDC084756; Wed, 17 Nov 2010 16:41:37 -0600 (CST) (envelope-from dan) Date: Wed, 17 Nov 2010 16:41:37 -0600 From: Dan Nelson To: Karl Vogel Message-ID: <20101117224137.GG57869@dan.emsphone.com> References: <20101117155006.GA88394@freebsd.org> <20101117195521.GF57869@dan.emsphone.com> <20101117214433.9D0DBBF95@kev.msw.wpafb.af.mil> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101117214433.9D0DBBF95@kev.msw.wpafb.af.mil> X-OS: FreeBSD 8.1-STABLE User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: clamav-milter 0.96.4 at email2.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.6 (email2.allantgroup.com [199.67.51.78]); Wed, 17 Nov 2010 16:41:38 -0600 (CST) X-Scanned-By: MIMEDefang 2.68 on 199.67.51.78 Cc: freebsd-questions@freebsd.org Subject: Re: a question regarding proper printf(3) formating and alignment X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2010 22:41:42 -0000 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@allantgroup.com