1 2 3 4 5 6 7 8 #!/bin/bash sum=$(awk '{sum +=$2} END { printf ("%f\n", sum) }' $1) points=$(cat $1 | wc -l) firstx=$(cut -f 1 $i | head -n 1) lastx=$(cut -f 1 $i | tail -n 1) delx=$(calc $lastx-$firstx) int=$(calc$delx*$sum/$points) echo $int  The command 'calc' refers to any of the one-line calculators described here. The script integrates the second column ("$2") of your data file. Save it as 'pmi' and call it with 'pmi data.dat'. The script takes 90 ms for 100000 values on my machine (measured with haui's great 'time' program). Haui might be able to reduce this execution time to a mere blink of the eye by perl magic. 8)