bash shell script which adds output of commands

Posted by John Kube on Super User See other posts from Super User or by John Kube
Published on 2010-04-22T17:22:42Z Indexed on 2010/04/22 17:34 UTC
Read the original article Hit count: 252

Filed under:
|
|

Let's say I have a command called foo which prints a number to the screen when called:

$foo
3

Let's also say I have another command called bar which prints another number to the screen when called:

$bar
5

I'm looking to write a shell script which will add together the output of foo and bar. How would I do that? (The outputs from the commands are not known ahead of time. They just so happen to have been 3 and 5 the last time they were run. They could have been something else.) Thanks!

© Super User or respective owner

Related posts about bash

Related posts about unix