#!/bin/bash plot() { gnuplot <=2{if ($1 < MinCost) MinCost = $1; if ($2 > MaxAtt) MaxAtt = $2; print NR,$1,MinCost,$2,MaxAtt;} ' $file > $name; plot $name; rm $name; done