Question

Present I can plot in batch like this

filename(n) = sprintf("x0%.3fgammamax.txt", n)
set term png size 800,600 enhanced
do for [ii=0:10]{
tempi=(ii+0.0)
outfile = sprintf('x0%.3fgammamax-pm3d.png',tempi)
set output outfile
splot filename(tempi) notitle with pm3d
}

But, Now I need to process the data before I plot using awk. The content of the file named addblanks.awk is

/^[[:blank:]]*#/ {next} # ignore comments (lines starting with #)
NF < 3 {next} # ignore lines which don't have at least 3 columns
$1 != prev {printf "\n"; prev=$1} # print blank line
{print} # print the line

If I don't need dynamic file name, I using the command:

splot "<awk -f addblanks.awk data.txt"  notitle with pm3d

However, I need dynamic file name still using awk now. The result should be like:

 splot "<awk -f addblanks.awk filename(tempi)"  notitle with pm3d

How to get it work?

Was it helpful?

Solution

You simply need to concat the two string with the .:

splot "<awk -f addblanks.awk ".filename(tempi)  notitle with pm3d

OTHER TIPS

This might work:

splot "<awk -v TEMPI="$tempi" -f addblanks.awk filename(TEMPI)"  notitle with pm3d

I have defined the awk variable with capital letters in order to prevent confusion. tempi="$tempi" should work as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top