Addition operation in shell

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/

http://blog.csdn.net/zwx19921215/article/details/21098391

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326221998&siteId=291194637