[PLUG] bash decimal interpretation

Chris Jantzen chris-plug at maybe.net
Wed Dec 3 02:48:02 UTC 2003


On Wed, Dec 03, 2003 at 02:40:01AM -0800, Jeme A Brelin wrote:
> 
> On Wed, 3 Dec 2003, Chris Jantzen wrote:
> > Try:
> >
> > for a in `seq 1 10`;do b=$[$a+5];printf "%02d %02d\n" $a $b;done
> >
> > (Std Disclaimer: printf is a bashism)
> >
> > Kills two birds in one stone, perhaps. Note lack of "-w" argument,
> > particularly.
> 
> Um... but what if I don't know how wide I need the output?  (considering
> it's in a script)

It'll just overflow the width. "5" becomes "05", but "123" becomes
"123". It does, however, beg the question of "why pad if you don't know
how wide you want it?"

-- 
chris kb7rnl =->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.pdxlinux.org/pipermail/plug/attachments/20031203/084bc08b/attachment.asc>


More information about the PLUG mailing list