A
A
Alexander Semenenko2019-08-21 10:23:09
linux
Alexander Semenenko, 2019-08-21 10:23:09

How to fold in bash?

I have a line in the script that calculates how much memory a certain user occupies:
ram=`ps -u $ID --no-headers -o rss`
The ram variable gets:
echo $ram
29448
18128
61672
29116
35376
How can I add these numbers correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Skyrimus, 2019-08-21
@semenenko88

ram=`ps -u $ID --no-headers -o rss | awk '{ sum += $1 } END { print sum }'`
echo $ram

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question