On Friday 09 July 2010 15:42:46 tartifola@gmail.com wrote: > On Fri, 9 Jul 2010 15:36:00 +0200 > > Guillaume Brunerie wrote: > > 2010/7/9 > > > > > Hi, > > > is there a way to obtain from the command line a series of strings like > > > > > > (1:3) (4:6) (7:9)... > > > > > > always with the same increment. I'm playing with 'seq' and 'sed' but > > > perhaps it's not the best approach. > > > Thanks, > > > A. > > > > Hi, > > You can use a for-loop : > > > > for (( i = 0; i < 5; i++ )) > > do > > > > echo -n "($(( 3 * i + 1 )):$(( 3 * i + 3))) " > > > > done > > Thanks for your help, it works perfectly. Just a curiosity, any possible > solution without a loop for? Actually there is a solution without loops. But it not as nice as a looping solution (for, while, until, ...). You can use recursive functions as a loop- replacement. But it's not as easy as a for-loop. ## recursive function expand() { (( $1 < 0 )) && return print -n "$(expand $(($1 - 1))) ($((3 * $1 + 1)):$((3 * $1 + 3)))" } ## call recursive function expand 20