If I do this:
touch {1,2,3}.txt
I get
1.txt 2.txt 3.txt
But if I do this
touch {"File 1", "File 2"}.txt
I don't get expected 'File 1.txt' 'File 2.txt'
. What is the proper approach in this case?
If I do this:
touch {1,2,3}.txt
I get
1.txt 2.txt 3.txt
But if I do this
touch {"File 1", "File 2"}.txt
I don't get expected 'File 1.txt' 'File 2.txt'
. What is the proper approach in this case?
Whitespace after the
,
causes the shell to parse your expression as two separate tokens, instead of as a brace expansion:You just need to remove the whitespace:
So
More compactly, you could also use
touch "File "{1,2}.txt
ortouch File\ {1,2}.txt
Alternatively, also in bash, this can be done in a for loop like so: