标签云

微信群

扫码加入我们

WeChat QR Code

I have a file with 500 lines of floating point numbers. What I want to do is take a line, and then subtract every line lower in linenumber from that line. An example nonworking script would be:for i in `seq 0 499`; do for ((j=0; j<i; j++)); do a=$(awk 'NR == i' i=$i inputfile) b=$(awk 'NR == j' j=$j inputfile) echo $(awk '{c=a-b};END{print c/NR}' a=$a b=$b) donedone > outputfileI'm not familiar with how to use awk, so any help would be appreciated. Thank you!Example:input:12345output:12 - 13 - 13 - 24 - 14 - 24 - 35 - 15 - 25 - 35 - 4Except instead of integers everything is a floating point number, and the subtractions should be evaluated


Can you give an example of input and expected output?

2019年04月19日05分23秒

Sorry, it is a bit confusing. I added an example.

2019年04月20日05分23秒