From owner-freebsd-questions Sun Dec 22 16:12:43 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 D676B37B401 for ; Sun, 22 Dec 2002 16:12:41 -0800 (PST) Received: from mail.bellavista.cz (mail.bellavista.cz [62.168.44.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id E659B43ED8 for ; Sun, 22 Dec 2002 16:12:40 -0800 (PST) (envelope-from neuhauser@bellavista.cz) Received: from freepuppy.bellavista.cz (freepuppy.bellavista.cz [10.0.0.10]) by mail.bellavista.cz (Postfix) with ESMTP id B379F5C; Mon, 23 Dec 2002 02:08:52 +0100 (CET) Received: by freepuppy.bellavista.cz (Postfix, from userid 1001) id 0C05B2FDC56; Mon, 23 Dec 2002 01:12:22 +0100 (CET) Date: Mon, 23 Dec 2002 01:12:22 +0100 From: Roman Neuhauser To: BSD Freak Cc: FreeBSD Questions Subject: Re: Padding expr output Message-ID: <20021223001222.GA42622@freepuppy.bellavista.cz> Mail-Followup-To: BSD Freak , FreeBSD Questions References: <108151f107bf32.107bf32108151f@mbox.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <108151f107bf32.107bf32108151f@mbox.com.au> User-Agent: Mutt/1.5.1i 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 # bsd-freak@mbox.com.au / 2002-12-23 10:57:19 +1100: > 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 printf(8) zero-padded integer and octal, respectively: roman@freepuppy ~ 1029:0 > printf "%03d\n" $(expr 8 + 1) 009 roman@freepuppy ~ 1030:0 > printf "%#o\n" $(expr 8 + 1) 011 roman@freepuppy ~ 1031:0 > -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message