Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.graphics.apps.gnuplot > #2937 > unrolled thread
| Started by | "Dan'l B" <dan.hinckley@gmail.com> |
|---|---|
| First post | 2015-06-17 18:00 -0700 |
| Last post | 2015-06-20 07:58 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.graphics.apps.gnuplot
Passing a GNUplot variable to system(/usr/bin/awk) "Dan'l B" <dan.hinckley@gmail.com> - 2015-06-17 18:00 -0700
Re: Passing a GNUplot variable to system(/usr/bin/awk) Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2015-06-20 01:43 +0200
Re: Passing a GNUplot variable to system(/usr/bin/awk) "Dan'l B" <dan.hinckley@gmail.com> - 2015-06-20 07:58 -0700
| From | "Dan'l B" <dan.hinckley@gmail.com> |
|---|---|
| Date | 2015-06-17 18:00 -0700 |
| Subject | Passing a GNUplot variable to system(/usr/bin/awk) |
| Message-ID | <f1dbf443-8220-4a41-bb98-a03c6c71acea@googlegroups.com> |
This line in GNUplot works fine:
system("/usr/bin/awk '/-1.98/{print $2 $1}' /path/to/myfile.txt")
But how would I pass a variable from GNUplot into that in place of the -1.98 value?
For example, using STATS_max_y from a plot command:
system("/usr/bin/awk '/STATS_max_y/{print $2 $1}' /path/to/myfile.txt")
That (and its variants) don't work, and I can't work out the formatting to do this correctly.
[toc] | [next] | [standalone]
| From | Hans-Bernhard Bröker <HBBroeker@t-online.de> |
|---|---|
| Date | 2015-06-20 01:43 +0200 |
| Message-ID | <cujnoeFgserU1@mid.dfncis.de> |
| In reply to | #2937 |
Am 18.06.2015 um 03:00 schrieb Dan'l B:
> This line in GNUplot works fine:
>
> system("/usr/bin/awk '/-1.98/{print $2 $1}' /path/to/myfile.txt")
>
> But how would I pass a variable from GNUplot into that in place of the -1.98 value?
About the most straightforward way would probably be to use gnuplot's
string manipulation functions to construct your awk command line, e.g.
awkcommand = sprintf("/usr/bin/awk '/%f/{print $2 $1}'
/path/to/myfile.txt", STATS_max_y)
system(awkcommand)
[toc] | [prev] | [next] | [standalone]
| From | "Dan'l B" <dan.hinckley@gmail.com> |
|---|---|
| Date | 2015-06-20 07:58 -0700 |
| Message-ID | <12ebabd7-2822-43f6-8067-aff922034bde@googlegroups.com> |
| In reply to | #2945 |
On Friday, June 19, 2015 at 7:43:13 PM UTC-4, Hans-Bernhard Bröker wrote:
> Am 18.06.2015 um 03:00 schrieb Dan'l B:
> > This line in GNUplot works fine:
> >
> > system("/usr/bin/awk '/-1.98/{print $2 $1}' /path/to/myfile.txt")
> >
> > But how would I pass a variable from GNUplot into that in place of the -1.98 value?
>
> About the most straightforward way would probably be to use gnuplot's
> string manipulation functions to construct your awk command line, e.g.
>
> awkcommand = sprintf("/usr/bin/awk '/%f/{print $2 $1}' /path/to/myfile.txt", STATS_max_y)
> system(awkcommand)
Perfect, many thanks, though the %g format works best for me here.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.graphics.apps.gnuplot
csiph-web