If I do this:
echo{,}
The result is:
echo
I don't really understand the {,} at the end and the result Thanks to clarify this.
I would start with something simpler to see how {}
works: As @anubhava linked, it generates strings. Essentially, it expands all the elements in it and combines them with whatever is before and after it (space is separator if you don't quote).
Example:
$ bash -xc 'echo before{1,2}after and_sth_else'
+ echo before1after before2after and_sth_else
before1after before2after and_sth_else
Note that there is a space between echo
and the arguments. This is not the case on what you have posted. So what happened there? Check the following:
$ bash -xc 'man{1,2}'
+ man1 man2
bash: man1: command not found
The result of the expansion is fed to bash and bash tries to execute it. In the above case, the command that is looking for is man1
(which does not exist).
Finally, combine the above to your question:
echo{,}
{,}
expands to two empty elements/stringsecho echo
bash
to executeecho
and its first argument is "echo"... so it echoes echo!