Awk command - calculation of columns

后端 未结 2 1531
旧巷少年郎
旧巷少年郎 2021-01-28 14:56

I am very new in Awk. I want to calculate the difference between first row column2 and second row column2. For instance:

Num1 Num2 
23   26
34   39
43   58
63           


        
2条回答
  •  不知归路
    2021-01-28 15:14

    You can try this,

    awk 'NR==1{col1=$1; col2=$2;} { print $1-col1,$2-col2; col1=$1;col2=$2}' yourfile
    

提交回复
热议问题