Difference operator

Dear All,

Good day, Just i would like to know that is there anything called difference operator in awk?

For example, if a file contains 5 columns (as shown below) with both negative and positive values:
Col1 Col2 Col3 Col4 Col5

I need to calculate the difference between Col1 and Col2, Col2 and Col3, Col3 and Col4, Col4 and Col5, and i need to print out the same in an output file as: New_Col1 New_Col2 New_Col3 New_Col4

Can any one help me in this regard?

Expecting your reply and thanks in advance.

Regards
Fredrick.

Try this, it substracts field 1 with field 2, field 2 with field 3 etc:

awk '{for(i=1;i<NF;i++){s=s FS $i-$(i+1)}print s;s=""}' file

What does s=s there signify? Is that like replasing some sting?

s=s FS $i-$(i+1)

This replaces the variable s with itself and adds a field separator FS and the substraction of the 2 fields after s.