grep string and output filename

Hello,

I have over 200 files and some of them have the string like "John price $200". I would like to grep the string. Then output the filename which found the string.

I have the following script, but it ONLY output the string
echo Please input list file name:
read listn
for file in `cat $listn.txt`
do
cat $file |grep "John price $200"
done

expect output:
filename: XXXXXX
found string: John price $200

thx,
happyv

Just change the commandline to grep to be:

grep "John price $200" $file /dev/null

Can use cut or awk to pick apart the output if you have to have it formatted differently

not sure what OS you are using, but grep -l (that's a lowercase L) will show just the filename, not the line that matches. Do a man on grep and it should tell you how to get just the name, or tell us the os and we might be able to help some more.

thx..but how can I check my OS in unix?