Store for loop results as a variable in bash

Viewed 23796

I have a loop similar to the following:

for time in ${seconds_list}; do
    echo "scale=2; (${cur_time}-${time})/3600" | bc
done

Of course, I could "echo" the results to a file and be done with it, but I think a more elegant approach would be to store all the for-loop results in one variable, that I could use at a later time. The variable containing all results would have to look something like this:

var='30.25
16.15
64.40
29.80'

Is there an easy way in which I can achieve this?

2 Answers
Related