0

I want to run this command

eval "cat <<EOF
$(cat /input.conf)
" > result.conf

However it's indenting the first line and showing this error:

warning: here-document at line 28 delimited by end-of-file (wanted `EOF')

How can I get this to not indent the first line as well as fix the warning?

Barmar
  • 741,623
  • 53
  • 500
  • 612
koonig
  • 67
  • 4
  • 3
    Indentation has nothing to do with this. You're missing the `EOF` tag to end the here-document. – Barmar Jul 26 '23 at 17:12
  • Is `EOF` inside `input.conf`? – Barmar Jul 26 '23 at 17:13
  • Why do you think the *first* line is being indented, and why would that matter? The only indentation that matters is the `EOF` line at the end of the here-doc. – Barmar Jul 26 '23 at 17:16
  • 1
    What exactly are you trying to accomplish with `eval`? – chepner Jul 26 '23 at 17:17
  • @pjh It's not executing the contents of input.conf, it's just catting it. – Barmar Jul 26 '23 at 17:18
  • This seems like it's just doing `cp input.conf result.conf` – Barmar Jul 26 '23 at 17:18
  • that's a ridiculous construction. `cat /input.conf > result.conf`. If you're using `eval` you're generally doing it wrong. – erik258 Jul 26 '23 at 17:36
  • I'm using eval to fill in some env variables in the input file and I'd like to place the result of evaluating the variables into another file. I put EOF at the end but it just prints the EOF at the end of the result.conf file – koonig Jul 26 '23 at 17:41
  • 1
    Don't do what you're trying to do as even if we could help you fix the syntax error it'd still be the wrong approach to doing anything. See the question I closed this as a duplicate off for how to really do what I think you're trying to do based on [your comment](https://stackoverflow.com/questions/76773578/bash-eof-showing-warnings?noredirect=1#comment135348695_76773578) "I'm using eval to fill in some env variables in the input file" and if that doesn't help you to do what you want then ask a new question about WHAT you're trying to do rather than HOW you're trying to do it. – Ed Morton Jul 26 '23 at 18:06

0 Answers0