Hi im having troubles with the following code:
#|/bin/tcsh
TOTALMOS=`grep -v "Last MO:" x.log | grep "Total: .* MOs" | grep "Total: .* MOs" | awk '{ print $2 }' | tr '\n' ' ' | awk '{ print $1 }'`
RADIONO=`grep -n "get radio no" x.log | cut -f1 -d:`
RADIONO2=`expr "$RADIONO" + 6`
RADIONO3=`expr "$RADIONO2" + "$TOTALMOS"`
SED=`sed -n ''$RADIONO2','$RADIONO3'p' x.log | awk '{ print $3 }' | tr '\n' ' '`
echo "$SED"
The output is the following:
5 8 2 4 0 10 6 11 1 3 1 9
Pease note: there are two breaks at the end of the script being "...1 9__"
Well what i really want it is SUM all the numbers excluding the final breaks that idk where they come from. My first thought was substitute the newlines with "+" and then make it work with expr but it does not work at all...
Please any advice?
Thanks in advance!
Best Regards.