Article 55XDV Make a countdown column with awk

Make a countdown column with awk

by
Drosera_capensis
from LinuxQuestions.org on (#55XDV)
Hello everyone,

A little question about awk.
Given a column of numbers in a "list" file.
0
1
2
3
4
5

I wish to print a list displaying (sum - value) at each row, as a countdown of the sum of the first list.
15
13
10
6
1
0

I have tried to set up a script to do it, but it does not work.

Code:cat list | awk ' BEGIN {S+=$1} END {a=$1} {print (S-$a)}'Would anyone has a solution for this?latest?d=yIl2AUoC8zA latest?i=VJ-TacMWWDU:lrFYikx8-OI:F7zBnMy latest?i=VJ-TacMWWDU:lrFYikx8-OI:V_sGLiP latest?d=qj6IDK7rITs latest?i=VJ-TacMWWDU:lrFYikx8-OI:gIN9vFwVJ-TacMWWDU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments