gnuplot bash 脚本变量
gnuplot bash script variables
我一直在创建一个快速 bash 脚本,它将生成一些资源编号并通过 gnuplot 显示它们。我 运行 在第二次更改 gnuplot 命令中的文件名以反映我的脚本为文件位置设置的变量时遇到了问题。示例代码如下。
知道我为什么会遇到这个问题吗?我猜 gnuplot 没有扩展我设置的变量,我只是不知道我需要改变什么。谢谢。
testFile=/var/log/testing.log
testFileTwo=/var/log/testingTwo.log
gnuplot -persist -e 'set xlabel "TIME"; set ylabel "PERCENT" ; set yrange [0:100]' -e 'plot ${testFile} smooth bezier, ${testFileTwo} smooth bezier'
我一运行这个脚本,我就收到以下错误。
plot ${testFile} smooth bezeri, ${testFileTwo} smooth bezier
^
line 0: invalid complex constant
Bash 不会扩展 '
单引号内的变量。如果在第二个 -e
之后使用 "
双引号,bash 将在将结果字符串传递给 gnuplot 之前扩展 ${testFile}
和 ${testFileTwo}
。
编辑:使用 -e "plot '${testFile}' ..."
,以确保 plot 收到引号内的名称。
我一直在创建一个快速 bash 脚本,它将生成一些资源编号并通过 gnuplot 显示它们。我 运行 在第二次更改 gnuplot 命令中的文件名以反映我的脚本为文件位置设置的变量时遇到了问题。示例代码如下。 知道我为什么会遇到这个问题吗?我猜 gnuplot 没有扩展我设置的变量,我只是不知道我需要改变什么。谢谢。
testFile=/var/log/testing.log
testFileTwo=/var/log/testingTwo.log
gnuplot -persist -e 'set xlabel "TIME"; set ylabel "PERCENT" ; set yrange [0:100]' -e 'plot ${testFile} smooth bezier, ${testFileTwo} smooth bezier'
我一运行这个脚本,我就收到以下错误。
plot ${testFile} smooth bezeri, ${testFileTwo} smooth bezier
^
line 0: invalid complex constant
Bash 不会扩展 '
单引号内的变量。如果在第二个 -e
之后使用 "
双引号,bash 将在将结果字符串传递给 gnuplot 之前扩展 ${testFile}
和 ${testFileTwo}
。
编辑:使用 -e "plot '${testFile}' ..."
,以确保 plot 收到引号内的名称。