Sample Header Ad - 728x90

Why does bash give the following result after brace expansion?

9 votes
1 answer
658 views
I am using linux and the following version of the bash:
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
When I type:
echo file{[1,2],3}.txt
I expect brace expansion to be done first, so:
echo file[1,2].txt file3.txt
After that, I expect it to stop there, since [1,2] is not a valid globbing. However, it gives the following as output:
file[1.txt file2].txt file3.txt
Why? List of files in current directory (result of ls command):
go.mod  hello.sh  hi  main.go
Asked by Yakog (517 rep)
Feb 22, 2025, 01:46 PM
Last activity: Feb 24, 2025, 12:24 PM