#!/bin/bash
for i in {1..50}
do
./ampl ampltst1 # generates different res.txt file each time
/usr/bin/gnuplot <<\__EOF
set xrange [-2:2]
set yrange [-2:2]
set term png
set output "image-${i}.png"
plot "res.txt" u 1:2 w lines, "res.txt" u 3:4 w lines, "res.txt" u 5:6 w li$
pause -1
__EOF
done
请帮我修复这个脚本!
答案 0 :(得分:3)
您可能遇到缩进问题:__EOF
必须没有任何前导空格:
...
/usr/bin/gnuplot <<\__EOF
set xrange [-2:2]
...
__EOF
done
此外,还不需要\
符号。
HERE-IS-DOCUMENT的内容也将缩进。 gnuplot可以吗?
如果不是,则必须删除缩进:
for i in {1..50}
do
./ampl ampltst1 # generates different res.txt file each time
/usr/bin/gnuplot <<__EOF
set xrange [-2:2]
set yrange [-2:2]
set term png
set output "image-${i}.png"
plot "res.txt" u 1:2 w lines, "res.txt" u 3:4 w lines, "res.txt" u 5:6 w li$
pause -1
__EOF
done