Gnuplot 如何在gnuscript中的循环中使用grep命令

Gnuplot 如何在gnuscript中的循环中使用grep命令,gnuplot,Gnuplot,对不起,我问了很多问题。 我有一个case.dat文件,它有多个列,我想根据gnuscript中的Colum2提取数据数组。 我尝试了下面的脚本,但它给了我错误 array="" do for [i=300:800:100] { # I mean start:end:increment. so it should read 300, 400, 500, 600, 700, 800 here val ="grep i case.dat" # Want to store the co

对不起,我问了很多问题。 我有一个case.dat文件,它有多个列,我想根据gnuscript中的Colum2提取数据数组。 我尝试了下面的脚本,但它给了我错误

array=""
do for [i=300:800:100] {  # I mean start:end:increment. so it should read 300, 400, 500, 600, 700, 800 here
val ="grep i case.dat"        # Want to store the command in a valuel/variable
print val > i.dat              #Here I need to store the data in i.dat
}
错误

我的bash脚本如下所示

##!/bin/bash
case="data"
for i in `seq 100 100 800`
do
       awk '$2=='$i'{print $0}' $case.dat > $i.dat
done

that I want to use at the start of the gnu-script so that the further operation can be done in the rest part of the gnu-script.
gnuplot脚本:

do for [i=300:800:100] {
   outfile = sprintf("%d.dat", i)
   command = sprintf("grep %d case.dat",i)
   set print outfile
   print system(command)
   unset print
}
这将创建单独的文件300.dat 400.dat 500.dat等等

如果您希望将这些数据子集完全保留在gnuplot内部,即不创建任何新文件,则可以创建命名数据块$data\u 300$data\u 400等:

do for [i=300:800:100] {
    eval( sprintf("set print $data_%3d", i) )
    print( sprintf("grep %d case.dat") )
    unset print
}
命名数据块通常可以在任何可以使用文件名的地方使用,例如。
用线条绘制$data\u 500

do for [i=300:800:100] {
    eval( sprintf("set print $data_%3d", i) )
    print( sprintf("grep %d case.dat") )
    unset print
}