awk '{ if ( oldline == $1 ) { print $1,($2-oldsp)/($3-oldtr) } oldsp=$2 oldtr=$3 oldline=$1 }' $1