Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Bash brace expansion with range of numbers

  • 13-10-2005 04:44PM
    #1
    Registered Users, Registered Users 2 Posts: 1,865 ✭✭✭


    One can use bash's brace expansion to do less typing.
    Eg:
    [din][~]$ echo foo{0,1,2,3,4,5,6}
    foo0 foo1 foo2 foo3 foo4 foo5 foo6
    

    However I'm conviced I can remember doing something like this:
    [din][~]$ echo foo{0..6}
    foo0 foo1 foo2 foo3 foo4 foo5 foo6
    

    And FYI:
    [din][~]$ bash --version
    bash --version
    GNU bash, version 2.05b.0(1)-release (powerpc-apple-darwin8.0)
    Copyright (C) 2002 Free Software Foundation, Inc.
    


Comments

  • Registered Users, Registered Users 2 Posts: 413 ✭✭padraigmyers


    Works fine for me, although i do have a much newer version of bash.
    [~ 17:21:30]$ echo foo{0..6} 
    foo0 foo1 foo2 foo3 foo4 foo5 foo6 
    
    [~ 17:22:15]$ bash --version 
    GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu) 
    Copyright (C) 2004 Free Software Foundation, Inc
    


  • Closed Accounts Posts: 95 ✭✭krinDar


    Syth wrote:
    However I'm conviced I can remember doing something like this:
    [din][~]$ echo foo{0..6}
    foo0 foo1 foo2 foo3 foo4 foo5 foo6
    


    This feature was added in version 3.0 of bash:

    http://cnswww.cns.cwru.edu/~chet/bash/NEWS

    Look for 'u' under new features.


  • Registered Users, Registered Users 2 Posts: 1,865 ✭✭✭Syth


    I updated bash (via darwin ports). I'm using v3 now. I'm happy. :D

    Thanks lad{,ettes}s. ;)


Advertisement