Hi everybody:
Could anybody tell me how can I do this task in AWK language.
I've two files (file1 & file2) where file1 its last row it has first field value equal that the first row in file2, thyen I want calculate the difference in other fields, and this values apply in file2. This is:
Then diff=$2(file2)-$2(file1)=217.83-214.468=3.362, then I would like to have this output:
19.83 214.468
28.67 231.34-diff
42.74 264.576-diff
.............................
.............................
This is:
19.83 214.468
28.67 227.978
42.74 261.214
.............................
.............................
Thanks Ambu23, but Ive tried to use it and I don know why, it appears this error:
./gir_int.sh: line 72: bc: command not found
I hope that it is because this command are not installed (?).
What do you recommend me ?.
but the second column does not correspond with the difference.
I did this (in my case):
tail -1 05080300.ddr | read x y z
head -1 mls_65.tmp1 | read a b c
if [ $a -eq $x ]
then
LC_ALL=en_DK awk -v var1=$b -v var2=$y ' BEGIN { dif=var1-var2 } { print $1, ($2-dif) } ' mls_65.tmp1 > mls_65.tmp2 #file2
fi