0

I have the code,

echo "set term postscript" |
echo "set output 'output.ps'" |
for FILE in output*; do
    echo "plot '${FILE}' u 1:2 w l t '1', '${FILE}' u 1:3 w l t '2', '${FILE}' u 1:4 w l t '3'"
done | gnuplot -persist

I want the first two lines to be printed before anything else inside gnuplot. How can I achieve this?

Best,

Jacob

1 Answer 1

2

Do I understand correctly that you are trying to "group" the first three commands and pipe their collective output into gnuplot? If so, you can write:

{
  echo "set term postscript"
  echo "set output 'output.ps'"
  for FILE in output* ; do
    echo "plot '${FILE}' u 1:2 w l t '1', '${FILE}' u 1:3 w l t '2', '${FILE}' u 1:4 w l t '3'"
  done
} | gnuplot -persist

Edited to add: Incidentally, you might find it more readable to break up your third echo across multiple lines:

    echo plot "'${FILE}' u 1:2 w l t '1'," \
              "'${FILE}' u 1:3 w l t '2'," \
              "'${FILE}' u 1:4 w l t '3'"

(echo joins its arguments with spaces, so this is equivalent to the previous. It's totally up to you which version you find easier to work with.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.