In the shell, let is used continuously, let needs to be written at the top of a line, and the variable name is used directly when adding a variable without adding $ in front of the variable name;
Total=0 for ((i=19;i<=23;i++)) do c=`grep applyToJoinGroup msg-processor-api.20170601$i.log | wc -l` # c=$($cmd) let Total=Total+c done for ((i=0;i<=9;i++)) do c=`grep applyToJoinGroup msg-processor-api.201706020$i.log | wc -l` let Total=Total+c done for ((i=10;i<=18;i++)) do c=`grep applyToJoinGroup msg-processor-api.20170602$i.log | wc -l` let Total=Total+c done echo "Total" $Total
Other reference articles:
http://blog.163.com/zhangjie_0303/blog/static/99082706201111152303363/