Apologies in advance since I am sure this is an easy problem. Nevertheless, here goes.cat blah.txtaa+2bb+4cc+10dd+31I would like to process blah.txt to produce the folowing:aa+0bb+2cc+6dd+16The notion here is that the first column might be a list of songs, and the second their start times.My hunch was to do this using awk. I thought of two arrays with numeric indices storing $1 and the running total of $2. My idea was to shift the numeric index for the running totals by 1.  tail -r blah.txt | awk -F + '{ for(i=0;i<=NR;i++) arr[i+1]+=$2; farr[i]=$1 } END { for(i=NR+1;i>1;i--) {if (i==NR) {print farr[NR] FS 0 } else { print farr[i] FS arr[i]}}}'This isn't concise, and what's more doesn't work. I am befuddled by the failure of the array making above all. Anyway, 'nuf said, could some kind person please put me out of my misery ?Tom
cumulative totals with shifted column
awk