Unix Shell Script Help - Grep

Hi,

I am new to UNIX Shell scripting, and will require some help.

I am trying to search a directory with a number of files for a specific word, then if that word is found in any of the files, then the filename is appended to a log file or result file by ">" command.

I have been trying to use grep, but so far when i Grep for word in a file, it outputs the word but not the file name.

I need to do this search to a directory with numerous files. For example if i am looking for the word "UBO888.gnt" in a directory full of files, i try the following, but doesnt work...

for file in `ls`
do
grep "UBO888.gnt" $file > outputresults.txt
done;

How do I search and output filenames?

Any help is appreciated.

Thanks.

use grep -l option..

you dont need to use loop here.

grep -l "UBO888.gnt" /directorypath/* >logfile

if you are in same directory where all files are present then simply.

grep -l "UBO888.gnt" * >logfile