Celeb Glow
news | March 29, 2026

Create multiple space separated files using touch with curly brace extension

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?

2 Answers

Whitespace after the , causes the shell to parse your expression as two separate tokens, instead of as a brace expansion:

$ printf '%s\n' {"File 1", "File 2"}.txt
{File 1,
File 2}.txt

You just need to remove the whitespace:

$ printf '%s\n' {"File 1","File 2"}.txt
File 1.txt
File 2.txt

So

$ touch {"File 1","File 2"}.txt
$ ls
'File 1.txt' 'File 2.txt'

More compactly, you could also use touch "File "{1,2}.txt or touch File\ {1,2}.txt

Alternatively, also in bash, this can be done in a for loop like so:

for f in "fil 1" "file 2"; do touch "$f".txt
done

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy