Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Gnuplot variables to a shell expression

Tags:

shell

gnuplot

I m trying to get the first element of a file within gnuplot:

data = "file.dat"
x = `cat data | head -n 2 | tail -n 1 | awk '{print $1}'`

but this keeps giving me the following error:

no such file or directory

I should write something like x = cat $data | head -n 2 | tail -n 1 | awk '{print $1}'

(with dollar)

Obviouly, this is also not correct.

Any ideas?

like image 217
Jun Avatar asked Dec 20 '22 00:12

Jun


1 Answers

You need to use a

set macro

and then use the symbol @ to get the value of the variable data (@ in Gnuplot is like $ in bash)

so this should work

x = `cat @data | head -n 2 | tail -n 1 | awk '{print $1}'`
like image 167
Tengis Avatar answered Jan 18 '23 08:01

Tengis