From owner-freebsd-questions Sun Dec 22 18:50:49 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 6D5FB37B406 for ; Sun, 22 Dec 2002 18:50:47 -0800 (PST) Received: from fep02-mail.bloor.is.net.cable.rogers.com (fep02-mail.bloor.is.net.cable.rogers.com [66.185.86.72]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9003143EDC for ; Sun, 22 Dec 2002 18:50:46 -0800 (PST) (envelope-from mj001@rogers.com) Received: from rogers.com ([24.101.253.54]) by fep02-mail.bloor.is.net.cable.rogers.com (InterMail vM.5.01.05.06 201-253-122-126-106-20020509) with ESMTP id <20021223025021.TENK513731.fep02-mail.bloor.is.net.cable.rogers.com@rogers.com>; Sun, 22 Dec 2002 21:50:21 -0500 Message-ID: <3E0679F5.7020508@rogers.com> Date: Sun, 22 Dec 2002 21:50:29 -0500 From: Mike Jeays User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.1) Gecko/20021005 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kurt Bigler Cc: BSD Freak , FreeBSD Questions Subject: Re: Padding expr output References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH PLAIN at fep02-mail.bloor.is.net.cable.rogers.com from [24.101.253.54] using ID at Sun, 22 Dec 2002 21:50:21 -0500 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 Kurt Bigler wrote: >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 > > > In bash: i=8 while [ ${#i} -lt "3" ] do i="0"${i} done echo $i To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message