Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Dec 2002 16:19:25 -0800
From:      Kurt Bigler <kkb@breathhost.net>
To:        BSD Freak <bsd-freak@mbox.com.au>, FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Padding expr output
Message-ID:  <BA2B968D.57E9%kkb@breathhost.net>
In-Reply-To: <108151f107bf32.107bf32108151f@mbox.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
on 12/22/02 3:57 PM, BSD Freak <bsd-freak@mbox.com.au> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BA2B968D.57E9%kkb>