Dear All,
I need to find the difference between two adjacent columns. The file is having 'i' columns and i need to find the difference between two adjacent columns (like $1 difference $2; $2 difference $3; .... and $(i-1) difference $i). I have used the following coding
HTML Code:
awk '{ for (i=1; i<NF; i++) if (($i - $i+1) > 10) print 1; else print 0}' input > output
While using the above in the command line, i am getting the values only in the first column of the output file. I need to print the difference in columns.
(for example; output $1 = input $1 difference input $2...etc..)
The problem here is, i need to get the difference between the two adjacent columns (for example: if the first column first element is 10 and the second column first element is 40, then $1 - $2 = -30, which is less than 10, so the output will be 0 in this case) But if you see the difference is 30. So i need to check the difference is > 10 or not.
Is there any difference operator in awk? (like $1 ~ $2).
I need your help in this regard.
Expecting your reply and thanks in advance.
Regards
Fredrick.