I have a file containing one column of number:
1
2
4
4
10
I would like to calculate the difference between each number using awk. The output should be like this :
1
2
0
6
How can I do it ?
I have a file containing one column of number:
1
2
4
4
10
I would like to calculate the difference between each number using awk. The output should be like this :
1
2
0
6
How can I do it ?
Just to make it shorter ...
In case awk is not a strict requirement, a shell solution:
DRYer
Code for GNU awk
Try the following code :
explanations