I'm trying to get all the regular files opened by all the processes in the current session. I have this code
while read pid
do
FILES_ACTUAL=$(lsof -p $pid | grep REG | wc -l)
done < <(ps -o pid,tt -u $USER | grep $CURRENT_TERMINAL | awk '{print $1}')
echo $FILES_ACTUAL
but I don't know how to add up, inside the while, the variable $FILES_ACTUAL.. I tried to use the awk command, but I couldn´t do it.