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! And here's the script: #!/bin/bash # # Get swap usage for all running processes if [ $UID -ne 0 ]; then printf "\a\nNot running as root - not all processes will be shown!\n\n" fi #set -x declare -i SUM=0 declare -i -g OVERALL=0 for DIR in /proc/[1-9]*; do PID=${DIR##*/} PROGNAME=$(ps -p $PID -o comm --no-headers) for SWAP in $(grep Swap $DIR/smaps 2>/dev/null|awk '{print $2}'); do let SUM=$SUM+$SWAP done if [ $SUM -gt 0 ]; then printf "PID=%6d\tSwap used: %8d\t(%s)\n" $PID $SUM $PROGNAME OVERALL=$[OVERALL+$SUM] SUM=0 fi done | sort -g -k 5 echo "Overall swap used: $OVERALL" #set +x -- To unsubscribe, e-mail: opensuse-support+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-support+owner@opensuse.org