Concatenate strings, files and program output in Bash

烈酒焚心 提交于 2019-11-30 03:17:16

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  >  output
echo "FOO" >> output
sed ...    >> output
echo "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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!