Im studying Linux.Now is reading group command.
Group commands in the current shell: { }
{ list; }
More in https://ss64.com/bash/syntax-brackets.html
The semicolon (or newline) following list is required.The braces are reserved words, so they must be separated from the list by blanks.
But When I test in my Ubuntu like {cat,2.txt} and {ls,-l}
highway@ubuntu:~/Desktop$ {cat,2.txt}
This is test2!
highway@ubuntu:~/Desktop$ {ls,-l}
total 12692
-rw-rw-r-- 1 highway highway 15 Jul 2 16:49 2.txt
...
The both command are not separated by blanks and also the semicolon not following the list.
But When I follow the quote,shell told me command not found
highway@ubuntu:~/Desktop$ { ls,-l; }
ls,-l: command not found
highway@ubuntu:~/Desktop$ { cat,2.txt; }
cat,2.txt: command not found
In the next test,I find in non-metacharacters only , can success.
highway@ubuntu:~/Desktop$ {cat.2.txt}
{cat.2.txt}: command not found
highway@ubuntu:~/Desktop$ {cat_2.txt}
{cat_2.txt}: command not found
highway@ubuntu:~/Desktop$ {cat#2.txt}
{cat#2.txt}: command not found
highway@ubuntu:~/Desktop$ {cat,2.txt}
This is test2!
So 2 questions I want to know
- why
{cat,2.txt}can work without following semicolon and no separated by blanks?
In other words,WHY the command{cat,filename}is parsed correctly by shell? - why in non-metacharacters only
,can success?
In other words,WHY the,is especial?