add numbers in shell script

cat dailyreports | grep "Important list" | awk -F":" '{print $2}' | awk -F" " '{print $1}'

hey guys, after running the above combination of cat and awk, i get the below output:

3
4
2
9

now, i need to add these numbers up all in one line. i dont know what to add to that cat and awk one liner to accomplish this addition. can someone please help me? thanks

Try

awk -F":" '/Important list/ {print $2}' dailyreports | awk '{print $1}'|while read w
do
   line="${line}${w}"
done

echo ${line}

Or in awk:

awk '
BEGIN {FS=":"}
{
	if ( $0 ~ /Important list/ )
		c=substr($2,1,1)c
}
END {print c} ' dailyreports 

or

grep "Important list" dailyreports| awk -F":" '{print $2}' | awk '{print $1}'| while read l; do echo -e "$l \c"; done

Which is almost the same Klashxx says in his first example :slight_smile: