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?
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?
You don't!
The
-c
is only for a script passed in as the first argument, not piped in via standard input as a heredoc does.Instead you use
-s
, which can be omitted if there are no other arguments passed to the script.Also, after replacing with
-s
you could also simplify:to:
Like most cats, the
cat
does nothing.