Concatenate strings, files and program output in Bash Concatenate strings, files and program output in Bash bash bash

Concatenate strings, files and program output in Bash


This works:

cat 1.css <(echo "FOO") <(sed ...) 2.css <(echo "BAR")


You can add all the commands in a subshell, which is redirected to a file:

(    cat 1.css    echo "FOO"    sed ...    echo BAR    cat 2.css) > output

You can also append to a file with >>. For example:

cat 1.css  >  outputecho "FOO" >> outputsed ...    >> outputecho "BAR" >> output cat 2.css  >> output

(This potentially opens and closes the file repeatedly)


You can do:

echo "$(command 1)" "$(command 2)" ... "$(command n)" > outputFile