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 outpu
In case awk is not a strict requirement, a shell solution:
set -- $(< file) p=$1; shift; while (($# > 0)); do echo $(($1 - p)); p=$1; shift; done
DRYer
set -- $(< file) while (($#>0)); do [[ -n $p ]] && echo $(($1-p)); p=$1; shift; done