shell - 在 Shell 脚本中使用 gnuplot 绘制图形

标签 shell

我必须在 shell 脚本的帮助下使用 gnuplot 绘制图表。 我已经编写了这段代码,但它不起作用。我想在 html 文件中绘制图表,以便我可以在浏览器中看到该图表。

 echo "set term canvas mousing size 500, 500
 set output "file_name.html"
 plot 'my_file.txt' with lines" | gnuplot

我已将此文件保存在桌面上的 .bash 中。 现在我在终端中写了这个,但它不起作用

sh file_name.bash

请有人帮我解决这个问题。从昨天开始我就完全被这件事困住了。 :-(

最佳答案

有多个错误,

  • 您在 echo 中使用双引号,这是行不通的。将其更改为单引号
  • 对多个 gnuplot 命令使用分号而不是换行符

所以生成的脚本应该是这样的

echo "set term canvas mousing size 500, 500; set output 'file_name.html'; plot 'my_file.txt' with lines" | gnuplot

cat << __EOF | gnuplot
set term canvas mousing size 500, 500
set output "file_name.html"
plot 'my_file.txt' with lines
__EOF

关于shell - 在 Shell 脚本中使用 gnuplot 绘制图形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11260573/

相关文章:

bash - 如何修改以下 ps 命令以以逗号分隔值 (CSV) 格式打印?

shell - sed:同一输出行上的多个模式

linux - 在 linux 中读取文件

ruby-on-rails - Ruby 守护进程不会在系统启动时执行

php - 从 PHP 启动 shell 命令

mysql - 一次对不同的表运行相同的 sql 查询(bash 脚本)

c++ - 如何避免每次编译时都必须键入 -std=c++11

linux - 无法使用 awk 中的系统导出变量

python - 没有 shell 转义序列的 git show/log,用于 python sh

bash - 用于重命名与 sha1sum 不匹配的文件夹和子目录中的每个文件的 Ubuntu 脚本