From owner-freebsd-questions Sun Dec 22 16:19:38 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0AC6937B401 for ; Sun, 22 Dec 2002 16:19:37 -0800 (PST) Received: from sccrmhc03.attbi.com (sccrmhc03.attbi.com [204.127.202.63]) by mx1.FreeBSD.org (Postfix) with ESMTP id 70D5B43EDC for ; Sun, 22 Dec 2002 16:19:31 -0800 (PST) (envelope-from kkb@breathhost.net) Received: from [192.168.1.63] (12-240-247-89.client.attbi.com[12.240.247.89]) by sccrmhc03.attbi.com (sccrmhc03) with SMTP id <2002122300192500300loo5se>; Mon, 23 Dec 2002 00:19:25 +0000 User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.3 Date: Sun, 22 Dec 2002 16:19:25 -0800 Subject: Re: Padding expr output From: Kurt Bigler To: BSD Freak , FreeBSD Questions Message-ID: In-Reply-To: <108151f107bf32.107bf32108151f@mbox.com.au> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG on 12/22/02 3:57 PM, BSD Freak wrote: > Hi all, > > I am usiung expr in a shell script and need to pad it's output to > always be 3 characters. An example will explain thing better: > > % expr 007 + 1 > Output is 8 > > I need the output to be 008 > > > I checked the expr man page, but nothing there solves my problem. > Anyone out there got one? Don't use expr to do the formatting. Use some sprintf-like capability in some scripting language that supports full functionality from the command-line. I think both awk and perl have that capability in some form. (Maybe someone else can be more specific.) Kurt Bigler > > Thanks in advance.... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message