#!/bin/bash cnt=0 for (( ofst = 0; ofst < 365; ofst++ )); do str=`date --date "2015/1/1 + $ofst days" +"%F"` mm=${str:5:2} d1=${str:8:1} d2=${str:9:1} if [ $mm -eq $((d1 + d2)) ]; then cnt=$((cnt + 1)) fi done echo $cnt