Linux Sum Lines Link to heading
# with awk
print "1\n2" | awk '{s+=$1} END {print s}'
# with jq
print "1\n2" | jq -s 'add'
# with python
print "1\n2" | python3 -c '
import sys;
total = sum(int(line) for line in sys.stdin)
print(total)
'
Celso Benedetti
# with awk
print "1\n2" | awk '{s+=$1} END {print s}'
# with jq
print "1\n2" | jq -s 'add'
# with python
print "1\n2" | python3 -c '
import sys;
total = sum(int(line) for line in sys.stdin)
print(total)
'