bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Brace expansion


From: Chris F.A. Johnson
Subject: Re: Brace expansion
Date: Sat, 4 Apr 2009 23:12:42 -0400 (EDT)
User-agent: Alpine 1.00 (LRH 882 2007-12-20)

On Sat, 4 Apr 2009, Ray Parrish wrote:

I'm attempting to study Brace Expansion at the same named page at bash-hackers.org and it states the following -
Generate numbers with a prefix 001 002 ...

Using a prefix:

for i in 0{1..9} 10; do printf "%d\n" "$i";done

However I am getting *this* output when running their command in Terminal In Ubuntu 8.04

ray@ray-desktop:~$ for i in 0{1..9} 10; do printf "%d\n" "$i";done
1
2
3
4
5
6
7
bash: printf: 08: invalid number
0
bash: printf: 09: invalid number
0
10

So... what gives???

    Numbers beginnig with 0 are required to be interpreted as octal
    numbers. 08 and 08 ar enot valid octal numbers.

for i in 0{1..9} 10; do printf "%02d\n" "$[i#0}";done

     Or:

printf "%02d\n" {1..10}

    Or, in bash4.0:

printf "%s\n" {01..10}


--
   Chris F.A. Johnson, webmaster         <http://woodbine-gerrard.com>
   ========= Do not reply to the From: address; use Reply-To: ========
   Author:
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]