I have a file with multiple  tags with a number next to it e.g.<Overall>4other <tags> and data<Overall>2other <tags> and data<Overall>3How would I search through the file and count up all the numbers next to the overall tag? and then divide the number by the number of overall tags, to get an overall average.So for example in the code above the average would be 3.And then loop through all the files in the current directory and list the overall average for each file. 
Sum value next to specific pattern
shell script;awk
Using awk (assuming all that is on overall lines is that and a number)awk 'x+=sub(/<Overall>/,){y+=$0}END{print AVG:,y/x}' filex is incremented for every successful sub of <Overall> with nothing. This means that it is only incremented on lines that contain <Overall>.The block after then adds the number that is left on the line to the total.END executes at the end of the program.In the end block the avg is printed.EDIT:for lots of filesawk 'x+=sub(/<Overall>/,){y+=$0}END{print FILENAME,AVG:,y/x}' LISTOFFILES