double round brackets
2017/12/27 Ishibashi
Let's use double round brackets in Bash, Ubuntu.
◎fast and useful way.
COUNT=0 for i in `seq 1 10` ;do COUNT=$(( COUNT + 1 )) echo for:${i} COUNT:${COUNT} done
× Using awk command (It is pitiful way) <- I used it previously.
COUNT=0 for i in `seq 1 10` ;do COUNT=`echo ${COUNT} |awk '{print $1 + 1}'` echo for:${i} COUNT:${COUNT} done
△ Using expr command.
COUNT=0 for i in `seq 1 10` ;do COUNT=`expr $COUNT + 1` echo for:${i} COUNT:${COUNT} done
◯ Using increment
COUNT=0 for i in `seq 1 10` ;do (( COUNT++ )) echo for:${i} COUNT:${COUNT} done
Keyword(s):
References: