在bash脚本+ gnuplot脚本中使用Gnuplot变量而不是Bash变量 [英] Use a Gnuplot variable instead of Bash Variable in a bash script + gnuplot script

查看:119
本文介绍了在bash脚本+ gnuplot脚本中使用Gnuplot变量而不是Bash变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想在bash脚本中使用gnuplot绘制smth,所以我有:

Hello I want to plot smth using gnuplot in a bash script so I have:

#!/bin/bash
//myscript
gnuplot -persist <<-EOFMarker
        plot 'd.csv' using 3:xtic(1) with boxes notitle, 'd.csv' using 0:($3+100):3 with labels
EOFMarker

我的问题是脚本替代bash变量(nothing + 100)替代脚本($ 3 + 100),而不是gnuplot替代脚本(每个值来自第三列+ 100). gnuplot?非常感谢

my problem is that the script substitute ($3+100) from bash variable (nothing+100) not from gnuplot (each value from 3rd column + 100).. how can I change the script in order to use the variable from gnuplot? thanks very much

推荐答案

它应该可以正常工作,$3为空,请考虑以下问题:

It should work, $3 is properly empty, consider this:

#!/bin/bash
set a b world
cat <<-EOF
hello $3
EOF

将输出hello world.如果要将文字$3发送到命令,则需要转义美元符号:

Will output hello world. If you want to send literal $3 to the command you will need to escape the dollar sign:

#!/bin/bash
set a b world
cat <<-EOF
hello \$3
EOF

这篇关于在bash脚本+ gnuplot脚本中使用Gnuplot变量而不是Bash变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆