From: Moody on 13 Jan 2010 03:54 In Bash 3.00.15(1): this works # echo {1..10}{a,b,c}{d,e,f} 1ad 1ae 1af 1bd 1be 1bf 1cd 1ce 1cf 2ad 2ae 2af 2bd 2be 2bf 2cd 2ce 2cf 3ad 3ae 3af 3bd 3be 3bf 3cd 3ce 3cf 4ad 4ae 4af 4bd 4be 4bf 4cd 4ce 4cf 5ad 5ae 5af 5bd 5be 5bf 5cd 5ce 5cf 6ad 6ae 6af 6bd 6be 6bf 6cd 6ce 6cf 7ad 7ae 7af 7bd 7be 7bf 7cd 7ce 7cf 8ad 8ae 8af 8bd 8be 8bf 8cd 8ce 8cf 9ad 9ae 9af 9bd 9be 9bf 9cd 9ce 9cf 10ad 10ae 10af 10bd 10be 10bf 10cd 10ce 10cf this really hecks # echo ${1..RANDOM}{a,b,c}{d,e,f} -bash: ${1..RANDOM}ad: bad substitution Or # echo {1..$RANDOM}{a,b,c}{d,e,f} {1..31738}{a,b,c}{d,e,f} Any idea?
From: pk on 13 Jan 2010 04:29 Moody wrote: > In Bash 3.00.15(1): > > this works > > # echo {1..10}{a,b,c}{d,e,f} > 1ad 1ae 1af 1bd 1be 1bf 1cd 1ce 1cf 2ad 2ae 2af 2bd 2be 2bf 2cd 2ce > 2cf 3ad 3ae 3af 3bd 3be 3bf 3cd 3ce 3cf 4ad 4ae 4af 4bd 4be 4bf 4cd > 4ce 4cf 5ad 5ae 5af 5bd 5be 5bf 5cd 5ce 5cf 6ad 6ae 6af 6bd 6be 6bf > 6cd 6ce 6cf 7ad 7ae 7af 7bd 7be 7bf 7cd 7ce 7cf 8ad 8ae 8af 8bd 8be > 8bf 8cd 8ce 8cf 9ad 9ae 9af 9bd 9be 9bf 9cd 9ce 9cf 10ad 10ae 10af > 10bd 10be 10bf 10cd 10ce 10cf > > > this really hecks > > # echo ${1..RANDOM}{a,b,c}{d,e,f} > -bash: ${1..RANDOM}ad: bad substitution > > Or > > # echo {1..$RANDOM}{a,b,c}{d,e,f} > {1..31738}{a,b,c}{d,e,f} # eval echo {1..$RANDOM}{a,b,c}{d,e,f}
From: johnb850 on 14 Jan 2010 10:54 On Jan 13, 1:54 am, Moody <nasir.mahm...(a)gmail.com> wrote: > In Bash 3.00.15(1): > > this works > > # echo {1..10}{a,b,c}{d,e,f} > 1ad 1ae 1af 1bd 1be 1bf 1cd 1ce 1cf 2ad 2ae 2af 2bd 2be 2bf 2cd 2ce > 2cf 3ad 3ae 3af 3bd 3be 3bf 3cd 3ce 3cf 4ad 4ae 4af 4bd 4be 4bf 4cd > 4ce 4cf 5ad 5ae 5af 5bd 5be 5bf 5cd 5ce 5cf 6ad 6ae 6af 6bd 6be 6bf > 6cd 6ce 6cf 7ad 7ae 7af 7bd 7be 7bf 7cd 7ce 7cf 8ad 8ae 8af 8bd 8be > 8bf 8cd 8ce 8cf 9ad 9ae 9af 9bd 9be 9bf 9cd 9ce 9cf 10ad 10ae 10af > 10bd 10be 10bf 10cd 10ce 10cf > > this really hecks > > # echo ${1..RANDOM}{a,b,c}{d,e,f} > -bash: ${1..RANDOM}ad: bad substitution > > Or > > # echo {1..$RANDOM}{a,b,c}{d,e,f} > {1..31738}{a,b,c}{d,e,f} > > Any idea? No answer yet, but, the core of the question is, how to nest a var in the expansion of a range. foo=10 echo ${1..$foo} {1 ..10} Kicked out the "text" not the range; I used eval, and I got; eval echo {1..$foo} 1 2 3 4 5 6 7 8 9 10 Back to your question; eval echo {1..$RANDOM} Woot, screen filled with 'numbers' ... Post back you final solution, this might handy. JB
From: johnb850 on 14 Jan 2010 12:11 On Jan 13, 1:54 am, Moody <nasir.mahm...(a)gmail.com> wrote: > In Bash 3.00.15(1): > > this works > > # echo {1..10}{a,b,c}{d,e,f} > 1ad 1ae 1af 1bd 1be 1bf 1cd 1ce 1cf 2ad 2ae 2af 2bd 2be 2bf 2cd 2ce > 2cf 3ad 3ae 3af 3bd 3be 3bf 3cd 3ce 3cf 4ad 4ae 4af 4bd 4be 4bf 4cd > 4ce 4cf 5ad 5ae 5af 5bd 5be 5bf 5cd 5ce 5cf 6ad 6ae 6af 6bd 6be 6bf > 6cd 6ce 6cf 7ad 7ae 7af 7bd 7be 7bf 7cd 7ce 7cf 8ad 8ae 8af 8bd 8be > 8bf 8cd 8ce 8cf 9ad 9ae 9af 9bd 9be 9bf 9cd 9ce 9cf 10ad 10ae 10af > 10bd 10be 10bf 10cd 10ce 10cf > > this really hecks > > # echo ${1..RANDOM}{a,b,c}{d,e,f} > -bash: ${1..RANDOM}ad: bad substitution > > Or > > # echo {1..$RANDOM}{a,b,c}{d,e,f} > {1..31738}{a,b,c}{d,e,f} > > Any idea? More details; In case we need to pad the random number up a bit. Passing the eval, to printf to control the output a little bit more. JB printf "%0.5d " `eval echo {1..$RANDOM}`|
|
Pages: 1 Prev: zsh or ksh glob for directories and symlinks to directories Next: issues using printf |