3 replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
source | link
2 it's not about globbing
| link

mkdir with globbingbrace expansion seems to fail when variablevariables are used

    Post Closed as "duplicate" by Stéphane Chazelas bash of
1
source | link

mkdir with globbing seems to fail when variable are used

Ubuntu 14.04.5 LTS GNU bash, Version 4.3.11(1)-release (x86_64-pc-linux-gnu)

mkdir -vp test{1..3}/{a,b,c}

works fine

mkdir: created directory 'test1'
mkdir: created directory 'test1/a'
mkdir: created directory 'test1/b'
mkdir: created directory 'test1/c'
mkdir: created directory 'test2'
mkdir: created directory 'test2/a'
mkdir: created directory 'test2/b'
mkdir: created directory 'test2/c'
mkdir: created directory 'test3'
mkdir: created directory 'test3/a'
mkdir: created directory 'test3/b'
mkdir: created directory 'test3/c'


S=1;E=3; LANG=EN mkdir -pv test{$S..$E}/{a,b,c}

mkdir: created directory 'test{1..3}'
mkdir: created directory 'test{1..3}/a'
mkdir: created directory 'test{1..3}/b'
mkdir: created directory 'test{1..3}/c'

seems not to work.

unsucessfull was single and double qouting as well.

S=1;E=3; LANG=EN mkdir -pv 'test{$S..$E}/{a,b,c}'
mkdir: created directory 'test{$S..$E}'
mkdir: created directory 'test{$S..$E}/{a,b,c}'


 S=1;E=3; LANG=EN mkdir -pv 'test{'$S'..'$E'}/{a,b,c}'
 mkdir: created directory 'test{1..3}'
 mkdir: created directory 'test{1..3}/{a,b,c}'

 S=1;E=3; LANG=EN mkdir -pv "test{S1..S3}/{a,b,c}"
 mkdir: created directory 'test{S1..S3}'
 mkdir: created directory 'test{S1..S3}/{a,b,c}'

i know i can use for loops, have limits with the amount of arguments, possible issues with folders, or use printf or similiar setups as shown in the "Similar Questions" parts.

However i rather want to know why this specific case of globbing fails for me.

i found a possible solution in a comment on this question

http://unix.stackexchange.com/questions/274182/bash-script-single-quotes-parameter-with-globbing-value

qouting the user galaxy You can use eval to expand the whole line before executing it, e.g. $out=(eval "grep ..."), however, this works only if your input is trusted. – which makes this

S=1;E=3; LANG=EN eval mkdir -pv "test{$S..$E}/{a,b,c}"

mkdir: created directory 'test1'
mkdir: created directory 'test1/a'
mkdir: created directory 'test1/b'
mkdir: created directory 'test1/c'
mkdir: created directory 'test2'
mkdir: created directory 'test2/a'
mkdir: created directory 'test2/b'
mkdir: created directory 'test2/c'
mkdir: created directory 'test3'
mkdir: created directory 'test3/a'
mkdir: created directory 'test3/b'
mkdir: created directory 'test3/c'

work.