From owner-freebsd-questions@FreeBSD.ORG Wed Nov 17 22:14:10 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 DD2C61065674 for ; Wed, 17 Nov 2010 22:14:10 +0000 (UTC) (envelope-from vogelke@hcst.net) Received: from beta.hcst.com (beta.hcst.com [192.52.183.241]) by mx1.freebsd.org (Postfix) with ESMTP id 887708FC27 for ; Wed, 17 Nov 2010 22:14:10 +0000 (UTC) Received: from beta.hcst.com (localhost [127.0.0.1]) by beta.hcst.com (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oAHME8eT015314 for ; Wed, 17 Nov 2010 17:14:08 -0500 Received: (from vogelke@localhost) by beta.hcst.com (8.14.3/8.14.3/Submit) id oAHME8X1015313; Wed, 17 Nov 2010 17:14:08 -0500 Received: by kev.msw.wpafb.af.mil (Postfix, from userid 32768) id 9D0DBBF95; Wed, 17 Nov 2010 16:44:33 -0500 (EST) To: freebsd-questions@freebsd.org In-reply-to: <20101117195521.GF57869@dan.emsphone.com> (message from Dan Nelson on Wed, 17 Nov 2010 13:55:21 -0600) Organization: Array Infotech X-Disclaimer: I don't speak for the USAF or Array Infotech. X-GPG-ID: 1024D/711752A0 2006-06-27 Karl Vogel X-GPG-Fingerprint: 56EB 6DBF 4224 C953 F417 CC99 4C7C 7D46 7117 52A0 References: <20101117155006.GA88394@freebsd.org> <20101117195521.GF57869@dan.emsphone.com> Message-Id: <20101117214433.9D0DBBF95@kev.msw.wpafb.af.mil> Date: Wed, 17 Nov 2010 16:44:33 -0500 (EST) From: vogelke+unix@pobox.com (Karl Vogel) 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 Reply-To: vogelke+unix@pobox.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2010 22:14:11 -0000 >> 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: #!/bin/ksh #> On Wed, 17 Nov 2010 13:55:21 -0600, >> Dan Nelson happily babbled in reply: D> I seem to remember /usr/bin/find doing this dynamically by expanding D> columns as it saw values that were larger than the previous max, but D> apparently not (I just tested it). I believe you're thinking of "file". -- Karl Vogel I don't speak for the USAF or my company When a man says it's a silly, childish game, it's probably something his wife can beat him at. --Epperson's law