jac
jac

Reputation: 71

Pipe a text file to gnuplot

From command line, I can plot part of the data of a text file as:

echo "plot \"< cat myfile | awk '{print \$2}'\" | gnuplot -persist

I would like to make a simple bash script (mygnuplot) that allows me to do:

cat myfile | awk '{print $2}' | mygnuplot

I have read all the thread but I still haven't figured it out. Can someone advise me. Thanks, Jacopo

Upvotes: 1

Views: 1115

Answers (1)

Christoph
Christoph

Reputation: 48440

To read data from stdin, use the - special filename:

awk '{print $2}' < test.dat | gnuplot -persist -e "plot '-'"

See also help special-filenames.

But, in general gnuplot has itself several possiblities to select columns and rows e.g. with using and every.

Upvotes: 1

Related Questions