[PLUG] bash decimal interpretation
Chris Jantzen
chris-plug at maybe.net
Wed Dec 3 02:08:02 UTC 2003
On Wed, Dec 03, 2003 at 01:59:28AM -0800, Jeme A Brelin wrote:
>
> I have to write little bash loops all the time. Usually, this is just to
> handle bulk renames and things. Fairly frequently, I have to deal with
> this booger:
>
> jbrelin at person:~/$ for a in `seq -w 1 10`;do b=$[$a+5];echo $a $b;done
> 01 6
> 02 7
> 03 8
> 04 9
> 05 10
> 06 11
> 07 12
> bash: 08: value too great for base (error token is "08")
>
> What's the deal with that crap?
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.
--
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/5fcd9bb8/attachment.asc>
More information about the PLUG
mailing list