Adding Elapsed time

I'm using the Bourne shell and trying to write a script that will add all the time that any particular user has been on the network for.

I've used last-h | grep "username" | cut -c 58-62 to get the times.
Then I wrote a script that takes the time and converts it into just minutes.

Now I want to add all the minutes together to arrive at a total time.

I'm using expr; I keep getting a non-numeric expression error..I guess that means that the numbers I'm generating are strings and not just numbers?

Is there a way to convert a string, such as "345" into an integer so that you can use expr on it?

Is there any better way to approach getting total time on the network for any particular user?

It would be helpful to see a sample of your converted data and the code that is trying to accumulate it. If your converted data is whole integers, then expr should work - you don't need to do any conversion on the ascii string.

If you have decimal points, expr will not handle it. You can pipe your data into the following command, which will accumulate the first word on each line, and will allow decimal points.

awk '{min=min+$1} END {printf "%8.2f\n",min}'