I think we've missed the point with the file note being wrapped in CODE tags. If this is one file, then I'm assuming that you want the count for each block. The output requested has the values for b and c in each section.
Not the prettiest solution, but this might work:-
#!/bin/ksh
mkdir /tmp/$$
while read line
do
if [ "$line" != "${line#Query=}" ]
then
Section="${line#Query=}"
else
echo "$line" >> /tmp/$$/$Section
fi
done < file_name
for file in /tmp/$$/*
do
echo "Query=$file"
uniq -c /tmp/$$/$file
done
Does that get you any closer? The output is the wrong way round for the counts, but that could be handled thus:-
....
for file in /tmp/$$/*
do
echo "Query=$file"
uniq -c /tmp/$$/$file | while read col1 col2
do
echo "$col2 $col1"
done
done
I hope that this helps.
Robin
Liverpool/Blackburn
UK
---------- Post updated at 03:55 PM ---------- Previous update was at 03:52 PM ----------
Oh, an update before I posted!
Okay, well addressing the post number 6, try something like:-
#!/bin/ksh
while read line
do
grep "^$line" file2 | cut -f2- -d" "
done < file1