~$ echo $(ls)  arguments.txt cecho.sh Desktop Documents Downloads example.txt Music Pictures Public     ~$ echo $(ls *.txt)  ls: cannot access *.txt: No such file or directory  Why does the 2nd subshell command fails?
Why can't I do ls *.txt in a subshell?
shell;quoting
Remove the quotes around *.txt and it should work. With quotes shell will look for the literal filename *.txt. To explore/experiment, try creating a file with name *.txt as touch '*.txt' and repeat the command.