我尝试编写一个脚本,该脚本将由shell执行,以使用目录中的几个txt文件在gnuplot中绘制图形中的多行。因此,如果我输入一张图片的命令,结果就像想象的那样。在这里你可以看到命令:
plot "test2.txt" using 2:1 w filledcurves lc "red" title "Red Channel",
"text2.txt" using 3:1 w filledcurves lc "green" title "Green Channel",
"text2.txt" using 4:1 w filledcurves lc "blue" title "Blue Channel"
现在我的脚本看起来像这样:
[...] for i in 'ls -1 *.txt'
do
cat $1|
tr ":()" " " |
gnuplot -p -e 'set terminal jpeg; set output "'$1'.jpeg";plot "/dev/stdin" using 2:1 w filledcurves lc "red" title "Red Channel", "/dev/stdin" using 3:1 w filledcurves lc "green" title "Green Channel", "/dev/stdin" using 4:1 w filledcurves lc "blue" title "Blue Channel"'
done
脚本编辑每个txt文件并创建一个jpg,但只有第一个图形," Red Channel"。我还在不同的行之间交替尝试了, \
这样的分离,但它没有起作用。还尝试使用''
代替" / dev / stdin"但一切都没有发生。
答案 0 :(得分:0)
您尝试执行的操作无效,因为您的第一个plot
将消耗整个stdin
。还有其他问题。我不是在电脑上测试,但我认为你会更接近:
for i in *.txt ; do
tr ‘:()’ ‘ ‘ < “$i” > /tmp/a.txt
gnuplot -pe ‘set terminal jpeg; set output “/tmp/a.jpg”; plot “/tmp/a.txt” ... ‘
mv /tmp/a.jpg “${i}.jpeg”
done