Note that there are some explanatory texts on larger screens.

plurals
  1. PObash deletes my file while looping "~$ ./program > file.dat" (gnuplot)
    text
    copied!<p>I'm doing some script on bash to plot data with gnuplot. But it doesn't work.</p> <p>I have a program which throws data to the command line. I collect that data on a file and then I loop this process over to get the desired result. Say I have this script</p> <pre><code> N = 10 ./program.exe &gt; data_$N.dat # Creating the data to be plotted for ((i = 0 ; i&lt;1 ; i++)) do # Dummy loop to throw all together to gnuplot echo "set size square" echo "set xrange[-$N-1:$N+1]; set yrange[-$N-1:$N+1];" echo "plot '-' using 1:2" for((j = 0 ; j &lt;= 9 ; j++)) do # Throwing the data to gnuplot echo "cat data_$N.dat" # Updating the file and overwriting on it echo "cat data_$N.dat | xargs ./program.exe &gt; data_$N.dat" | bash echo "e" echo "pause 0.5" done done | gnuplot -persist # Throwing the formatted data to gnuplot </code></pre> <p>So, basically I throw formatted text to gnuplot from a file, changing the content of it, but without changing the name of the file. </p> <p>Of course, I don't wanna change the name of the file because I make the calculations corresponding to that step with that file, and then I overwrite the file with the updated data. Kind of a buffer. The computational flow would be</p> <pre><code>./program.exe &gt; data.dat # Making the initial data begin gnuplot loop throw data to gnuplot "cat data.dat | xargs ./program.exe &gt; data.dat" # update data overwriting file end gnuplot loop pipe all the script to gnuplot </code></pre> <p>Hope is clear and you can help me :). Thanks!</p> <p>PD. I'm a physicist.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload