awk 在 gnuplot 命令的第二部分或子图中不起作用
Awk not working in the second part or sub plot of the gnuplot command
通过 gnuplot 我试图在图表上打印一条平均线,但它不起作用,如果我在第二部分中使用 awk
命令或像这样的第二个子图命令
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
"<awk '{sum += } END {print sum/NR}' iops.1.log" with lines title "avg iops"
但是如果我直接给出我在 bash 命令行上 运行 相同的 awk 命令得到的值,那么该行会像这样打印。
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
4590 with lines title "avg iops"
上面的行在第二个子图中仅使用一个值 (4590) 打印了图中的 运行ning 平均线
到底发生了什么,为什么它不能正常工作?
这可能是一个错误,但幸运的是你可以在 gnuplot 中计算平均 y 值而不需要 awk:
stats "iops.1.log" nooutput
ave=STATS_sum_y/STATS_records
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
ave with lines title "avg iops"
当使用 plot "<awk ..."
和 awk
命令 returns 绘制单个数字时,您实际上拥有一个包含单个数字的 数据文件 数字。
与此相反,调用 plot 4560
绘制一个 函数 ,然后在整个 x 范围内绘制。
如果你想坚持使用 awk
,或者只是作为替代方案的解释,你可以
avg = system("<awk '{sum += } END {print sum/NR}' iops.1.log")
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
int(avg) with lines title "avg iops"
结构"<..."
给出了一个管道文件。要计算和绘制平均值,您可以使用
背部抽搐:
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
`awk '{sum += } END {print sum/NR}' iops.1.log` with lines title "avg iops"
通过 gnuplot 我试图在图表上打印一条平均线,但它不起作用,如果我在第二部分中使用 awk
命令或像这样的第二个子图命令
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
"<awk '{sum += } END {print sum/NR}' iops.1.log" with lines title "avg iops"
但是如果我直接给出我在 bash 命令行上 运行 相同的 awk 命令得到的值,那么该行会像这样打印。
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
4590 with lines title "avg iops"
上面的行在第二个子图中仅使用一个值 (4590) 打印了图中的 运行ning 平均线
到底发生了什么,为什么它不能正常工作?
这可能是一个错误,但幸运的是你可以在 gnuplot 中计算平均 y 值而不需要 awk:
stats "iops.1.log" nooutput
ave=STATS_sum_y/STATS_records
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
ave with lines title "avg iops"
当使用 plot "<awk ..."
和 awk
命令 returns 绘制单个数字时,您实际上拥有一个包含单个数字的 数据文件 数字。
与此相反,调用 plot 4560
绘制一个 函数 ,然后在整个 x 范围内绘制。
如果你想坚持使用 awk
,或者只是作为替代方案的解释,你可以
avg = system("<awk '{sum += } END {print sum/NR}' iops.1.log")
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
int(avg) with lines title "avg iops"
结构"<..."
给出了一个管道文件。要计算和绘制平均值,您可以使用
背部抽搐:
plot "iops.1.log" using (/1000):2 with lines title "job 1",\
`awk '{sum += } END {print sum/NR}' iops.1.log` with lines title "avg iops"