嗨! 我有编写bash脚本运行50次我的脚本生成数据文件,然后将其绘图文件的问题。 我这样写了,但是不起作用
#!/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
请帮我解决这个脚本!
可能你有缩进的问题: __EOF
必须没有任何前导空格:
... /usr/bin/gnuplot <<\__EOF set xrange [-2:2] ... __EOF done
另外\
符号不是必需的。
此外,这里的内容将被缩进。 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