In bash, given these files:$ cat noquotes.txts/a/b/g$ cat quotes.txts/a/b/gWhy does$ echo aaa | sed -e $(cat noquotes.txt)bbbsucceed, but$ echo aaa | sed -e $(cat quotes.txt)sed: 1: s/a/b/g: invalid command code fails?If if run set -x first, then I see that$ echo aaa | sed -e $(cat noquotes.txt)+ echo aaa++ cat noquotes.txt+ sed -e s/a/b/gbbband$ echo aaa | sed -e $(cat quotes.txt)+ echo aaa++ cat quotes.txt+ sed -e 's/a/b/g'sed: 1: s/a/b/g: invalid command code So it seems like there are extra quotes being inserted around the contents of noquotes.txt, but not around quotes.txt.
command substitution - cat file inserts quotes
bash;quoting;command substitution