W dniu 29.11.2019 o 15:57, Peter Suetterlin pisze:
Hi list,
while not realy OS related, here's an issue that twists my mind:
I have modified some script I found (was pointed to via some article...) to generate a list of processes that use swap, and how much.
It's attached below. The issue is line 23, the end of the for loop. If I omit piping the output through the sort command I get an unsorted list, and a correct OVERALL sum.
If I use the pipe, last output will be
Overall swap used: 0
WTF!? OVERALL is nicely added up in the loop, I can do echos/prints and see how it increases. After the pipe, it's zero again. I tried the 'set -x', but that didn't give me a clue what is happening there. Is that really expected behavior? What am I doing wrong?
Thanks for any insight!
This might be helpful: https://wiki.bash-hackers.org/scripting/processtree#bash_playing_with_pipes