need help with grep

Hi,
I used grep command to search for names in a file and it's code is
match=$(grep -c "$output1" outputfiles.txt )
if [ $match = 0 ]
then
echo $match
else
echo "match is geater than 1"
fi

where output1 is variable containing those names and outputfiles.txt is the file name. I tried this by using two strings:

  1. prod_rel_post_entr_au_interface-08_10_03.csv 3 times
  2. au_interface-08_10_03.csv 1 time

but my code is giving me 0 for only one time though there should be two 0s in the output
I think grep command is taking both names similar coz au_interface-08_10_03.csv part is present in prod_rel_post_entr_au_interface-08_10_03.csv.
Can anybody help me with this PLEASE

I also checked man grep but it didn't help me.

What about using the ^ to anchor your search term to the beginning of the line?

grep -c "^$output1" outputfiles.txt

grep -c reports the number of matching lines, not the number of occurrences.

Try grep -c -o pattern file or grep -o pattern file | wc -l