#!/usr/bin/env bash
while read line; do
n=${line%%|*}
[[ ${line##*|} == TOTAL ]] && continue
((total+=n))
echo $line
done
echo $total\|TOTAL