Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
In shell script a command output gives integer number like :
xxx$> xxxx 10 20 30
I want to add those integer values and get sum value. What is the simplest way to do..?
Supposing your script is named xxxx, you could do :
xxxx
xxxx | awk '{sum+=$1} END {print sum}'
Which would print the sum of the integers printed by xxxx :
~$ xxxx 10 20 30 ~$ xxxx | awk '{s+=$1} END {print s}' 60
Add a comment
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.