I am back with a simple Linux command. This command will let you sum up the numbers line by line on Linux shell. There are two most commonly used and easiest ways to do so.
Create a file named “numbers” containing following random numbers:
3
8
-1
5
0
10
200
151
-20Sum Numbers using Awk
$ awk 'BEGIN{sum=0}{sum+=$1}END{print sum}' numbersSum Numbers using jq
jq is a really superb parser for JSON data. But this handy tool is really a quick option to sum numbers.
$ jq -s 'add' numbers
356I am keen to hear more handy commands from you all. Keep posting.