A solution with awk
awk '
NR==1 {split($0,a)}
NR==2 {split($0,b)}
END {for(i=1;i<=NF;i++) printf "%d ", b[i]-a[i]}
' input.txt
gives a result of
0 0 8 6 4 2
Since awk interpret strings without valid numbers as 0 during arithmetic operations, in case you want to remove the results in which the source field contains non-numeric values, you can do this by adding an additional condition.
awk '
NR==1 {split($0,a)}
NR==2 {split($0,b)}
END {
for(i=1;i<=NF;i++)
if(a[i] ~ /^[0-9]+$/ && b[i] ~ /^[0-9]+$/)
printf "%d ", b[i]-a[i]
}
' input.txt
gives a result of
8 6 4 2
awk '{$temp=$3-prev3; prev3=$3}{print $temp}'
. The only limitation is i am using tsch on CentOS. I know tsch is inferior compared to other interpreter but this is what i have to use. I tried this too but didnt get what i wantcat tmpfile | awk '{for(i=3;i<=NF;i++){$temp[i]=$i-prev; prev=$i;print $temp[i]}}'