#!/bin/bash for (( i=1; i<=3; i++ )) do echo "No.$i" for j in 'ABCDEFG' do sed -n "/^$i/p" *| grep "$j" | wc -l done done