4
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 arithmetically add together the output of foo
and bar
(3+5=8). 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.)
2What do you mean by adding together? Are the program outputs always integers and you want 3+5=8 or are they strings and you want '3'+'5'='35'. – Benjamin Bannier – 2010-04-22T17:33:26.860
1they're integers, and I'm looking to add them (3+5=8), not concatenate them – John Kube – 2010-04-22T17:36:49.050