Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a Gnuplot variable instead of Bash Variable in a bash script + gnuplot script

Hello I want to plot smth using gnuplot in a bash script so I have:

#!/bin/bash
//myscript
gnuplot -persist <<-EOFMarker
        plot 'd.csv' using 3:xtic(1) with boxes notitle, 'd.csv' using 0:($3+100):3 with labels
EOFMarker

my problem is that the script substitute ($3+100) from bash variable (nothing+100) not from gnuplot (each value from 3rd column + 100).. how can I change the script in order to use the variable from gnuplot? thanks very much

like image 758
AdriansIdea Avatar asked Feb 20 '26 08:02

AdriansIdea


1 Answers

It should work, $3 is properly empty, consider this:

#!/bin/bash
set a b world
cat <<-EOF
hello $3
EOF

Will output hello world. If you want to send literal $3 to the command you will need to escape the dollar sign:

#!/bin/bash
set a b world
cat <<-EOF
hello \$3
EOF
like image 112
Andreas Louv Avatar answered Feb 22 '26 00:02

Andreas Louv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!