#!/bin/bash
sum=0
row=0
while read -r i;
do
    a=0
    j=`echo $i | wc -L`
    for((k=0;k<j;k++));
    do
        if [[ ${i:k:1} =~ (1|2|3|4|5) ]];
        then
            let a++;
        fi  
    done
    let row++;
    let sum+=a;
    echo "line${row} number:${a}"
done < nowcoder.txt
echo "sum is ${sum}"