help with find command

Hi ,

I want to list all the files from a directory (also in the sub directories) which contain a particular word.
If I am looking for a word ashwin_xyz , i don want files to be listed if they contain abc_ashwin_xyz. I am looking for files with the exact work and not if it is in between a string.

I am using the below command but it lists all the files

find . -type f -exec /usr/xpg4/bin/grep -ilE 'ashwin_xyz '  {} \;

Is there a way to avoid the files if the string is in between a word.

can u just try the option -w in grep command which matches the word exactly ashwin_xyz

use w option in grep

find . -type f -exec /usr/xpg4/bin/grep -wilE 'ashwin_xyz'  {} \;

hi,

I am not able to use -w option for grep in find command. It is throwing an error.
I am able to use it seperately in grep though.

find . -type f -exec /usr/xpg4/bin/grep -wilE 'ashwin_xyz'  {} \;
 
Error is :
Usage:  grep [-c|-l|-q] [-bhinsvwx] pattern_list [file ...]
        grep [-c|-l|-q] [-bhinsvwx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -E [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -E [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]
        grep -F [-c|-l|-q] [-bhinsvx] pattern_list [file ...]
        grep -F [-c|-l|-q] [-bhinsvx] [-e pattern_list]... [-f pattern_file]... [file...]