Calculate difference between consecutive data points in a column from a file

 

 

cat > temp001
5
10
12
6
9
12
5


 awk 'p{print $0-p}{p=$0}' temp001
5
2
-6
3
3
-7

 

REF:

https://www.unix.com/shell-programming-and-scripting/130727-how-subtract-adjacent-lines-single-column.html

 

posted @ 2017-12-06 01:32 emanlee 阅读(...) 评论(...) 编辑 收藏