【发布时间】:2020-08-03 07:05:35
【问题描述】:
我在 bash 脚本中有以下代码,用于准备输入数据以进行绘图。
代码在 gnuplot 解释器中运行时执行良好,但在 bash 脚本中,它用第二个 bash 参数替换了 $2,这意味着 ${outdir}/counts.txt 数据文件的列 2(输入文件没有不再处理情节)
如何编辑它以使 $1 和 $2 对 gnuplot 块保持私有?
#!/bin/bash
.. bash code
gnuplot <<-EOFMarker
set datafile separator ","
set key autotitle columnhead
set style line 1 \
linecolor rgb '#0060ad' \
linetype 1 linewidth 2 \
pointtype 7 pointsize 1.5
set yrange [*:100]
set xlabel "mappability %"
set ylabel "% above threshold"
max(a,b)=a>b?a:b
a=-99999999.
set terminal pngcairo
set output 'mappability_plot.png'
plot '${outdir}/counts.txt' using 1:(a=max(a,$2),0/0) notitle, \
'' using 1:(100*$2/a) notitle with linespoints linestyle 1
EOFMarker
【问题讨论】: