In unix/awk codeEssentially, I need to iterate through the file (data1.txt) and count the number of times the substr($0,29,2) of each line of the file == 04.data1.txt:6597243042 201603050011000031401528521530190001270002006597243042 201603050011000031401703061903060200000002006597243042 201603050011000031401705521905520200000002006597243042 201603050011000031402014302015430001130004006592311319 201603050411000034600727190728390001200012006592311319 20160305041100003460072927072952000025001200In this case only 2 lines of the file (data1.txt) fulfill the condition (substr($0,29,2)==04)I am stuck at finding a way to do soBelow is my unix/awk codeFilename=deffile=data1.txt#awk '{count1=0}'while IFS= read linedo   awk '{ if (substr($0,29,2)==04) {print substr($0,29,4)}}' done <$fileHow can I count this?
Count times an expression is true in awk.
text processing;awk