Linux 通过bash脚本实现Gnuplot
我需要使用bash脚本生成图形gnuplot,因为我有多个文件要打印Linux 通过bash脚本实现Gnuplot,linux,bash,shell,gnuplot,Linux,Bash,Shell,Gnuplot,我需要使用bash脚本生成图形gnuplot,因为我有多个文件要打印 while [ $j -lt 30 ]; do if [ -f ./MyFile[$j] ]; then load 'Plot_Histogramma.plt' fi j=$(( $j + 1 )) done 在“Plot_hisgrama.plt”中,我有 因此,我需要一种方法将索引变量从脚本传递到gnuplot。我试过使用echo,printf和export,但可能我做错了什么 我认为您可
while [ $j -lt 30 ];
do
if [ -f ./MyFile[$j] ]; then
load 'Plot_Histogramma.plt'
fi
j=$(( $j + 1 ))
done
在“Plot_hisgrama.plt”中,我有
因此,我需要一种方法将索引变量从脚本传递到gnuplot。我试过使用
echo
,printf
和export,但可能我做错了什么 我认为您可能误用了数组:
while [ $j -lt 30 ]; do
if [ -f ./${MyFile[$j]} ]; then
load 'Plot_Histogramma.plt'
fi
j=$(( $j + 1 ))
done
然后我相信另一个剧本应该是这样的:
set output "${MyFile[$j]}.eps"
plot "./${MyFile[$j]}" using 2:1 title "MyTitle" with boxes ls 7 lc rgb "blue"
也可能这个链接有帮助:在我看来,您希望在“Plot\u hisgrama.plt”中看到
MyFile[0].eps
等。这真的是文件名吗?在我看来似乎有点不寻常,我有一点印象,您可能会谈论来自bash的变量,它看起来像bash中的${MyFile[0]}
。如果不是这样的话,算了吧,只是一个评论……这很正常。您可以告诉gnuplot写入postscript、jpg、png等。。它只是设置输出文件的格式(如果不是显示)
set output "${MyFile[$j]}.eps"
plot "./${MyFile[$j]}" using 2:1 title "MyTitle" with boxes ls 7 lc rgb "blue"