意外的 EOF?

Unexpected EOF?

我一直在尝试使用 Bash 在 GNUPLOT 中创建图表。据我了解,我的以下代码应该将以下行输入到 gnuplot 命令中,直到它到达 EOF。然后我将 "set" 行和 "plot" 行发送到 gnuplot 并用 EOF 跟进,这应该结束对 gnuplot 命令的输入。

for FILE in ./tempFolder*.done; do
    gnuplot <<EOF
    set datafile separator ","
    set xlabel "Hour"
    set ylabel "Temperature"
    set term png
    set output "${FILE}.png"
    plot "${FILE}" using 1:3 with errorbars title "Temperature/Time"
    EOF
done

但是,我收到以下错误消息:"Syntax error: end of file unexpected (expecting "完成")"

当我在脚本外的 Bash 中输入 try this 时,它似乎工作正常。有人对我做错了什么有任何指示吗?

您不能缩进结尾 EOF;它必须在行的开头。

如果您使用 <<-EOF 而不是 <<EOF,shell 将从此处文档的每一行中删除所有前导 制表符 ,包括结尾 EOF.