From owner-freebsd-questions Wed May 10 14:54:12 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mail2.x-treme.gr (mail2.x-treme.gr [212.120.196.24]) by hub.freebsd.org (Postfix) with ESMTP id 19F6037BA6A for ; Wed, 10 May 2000 14:53:57 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from hades.hell.gr (pat15.x-treme.gr [212.120.197.207]) by mail2.x-treme.gr (8.9.3/8.9.3/IPNG-ADV-ANTISPAM-0.2) with ESMTP id AAA19380; Thu, 11 May 2000 00:53:42 +0300 Received: (from charon@localhost) by hades.hell.gr (8.10.1/8.10.1) id e4ALdgx58044; Thu, 11 May 2000 00:39:42 +0300 (EEST) Date: Thu, 11 May 2000 00:39:42 +0300 From: Giorgos Keramidas To: Dan Larsson Cc: questions@FreeBSD.ORG Subject: Re: making even columns in sh Message-ID: <20000511003941.A57999@hades.hell.gr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: ; from dl@tyfon.net on Wed, May 10, 2000 at 09:43:29AM +0200 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, May 10, 2000 at 09:43:29AM +0200, Dan Larsson wrote: > I've written a simple script to display usernames with their $HOME as > root (chrooted). The $HOME variable is extracted with awk and sed. > > However as usernames are not all the same lenght the columns (username > chroot/path ) don't run straight down, that is the chroot/path column > start depends on how long the username is. > > Is there some way I can manipulate the rows so that the second column > is displayed in an 'orderly' fashion using sh? Yet another pass through awk can make things a lot more beautiful. Try something like: % your commands here | awk '{ printf "%-8s %s\n", $0; }' The %-8s format string means print the argument in a string that is 8 characters wide, but left justified. More elaborate formats are possible, but that is probably off-topic. Ciao, Giorgos. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message