line=`cat nowcoder.txt | wc -l` u='0' for ((i=1;i<=$line;i++));do num1=`sed -n ''$i'p' nowcoder.txt` num2=`sed -n ''$i'p' nowcoder.txt | tr -d [12345]` num=`expr ${#num1} - ${#num2}` echo line$i" "number:$num u=`expr $u + $num` done echo sum is $u