Home > Mobile >  here-document with bash -c
here-document with bash -c

Time:12-17

This example script:

cat <<- EOF | bash -c
    command1 args
    command2 args
    command3 args
    command4 args
    command5 args
EOF

Returns: bash: -c: option requires an argument
How do I use bash -c with here-document?

CodePudding user response:

If you want to combine here-docuemnt with bash -c, try this :

bash -c "$(cat <<- EOF
    command1 args
    command2 args
    command3 args
    command4 args
    command5 args
EOF
)"
  • Related