我一直在创建一个快速的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发布于 2015-12-07 20:38:01
Bash不会在'单引号中展开变量。如果在第二个"之后使用-e双引号,则bash将在将结果字符串传递给gnuplot之前展开${testFile}和${testFileTwo}。
编辑:使用-e "plot '${testFile}' ...",以确保绘图收到引号内的名称。
https://stackoverflow.com/questions/34142709
复制相似问题