Looking for command(s)/ script to find a text string within a file

I need to search through all files with different file suffixes in a directory structure to locate any files containing a specific string

find . -name '*.*' -exec grep -ilw 'string_name' {} \;

Will this satisfy your requirement ?.

I go for, :smiley:

find . -name '*.*' -print | xargs grep -il 'pattern'

These examples helped. Thank you.

I do not use shell scripting much. Now I can learn from these results.

The results were :

devr> find . -name '*.*' -exec grep -ilw 'MAXCOMB' {} \;
./IPY0115.prog
./IPY0130.pl
./condir_and_copy_daily.sh
./IPY0130_old.pl
devr> find . -name '*.*' -exec grep -ilw 'maxcomb' {} \;
./IPY0115.prog
./IPY0130.pl
./condir_and_copy_daily.sh
./IPY0130_old.pl
devr> 
devr> | xargs grep -il 'maxcomb' {} \;                      <
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
./IPY0115.prog
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
./IPY0130.pl
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
./test_file_shell.sh
grep: can't open {}
grep: can't open ;
./dir_copy_daily_files.sh
./dir_copy_biweekly_files.sh
./condir_and_copy_biweekly.sh
./condir_and_copy_daily.sh
grep: can't open {}
grep: can't open ;
grep: can't open {}
grep: can't open ;
./doi_dnld_files.prog
./IPY0130_old.pl
grep: can't open ./View
grep: can't open for
grep: can't open value_set
grep: can't open Role_id.sql
devr> rgs grep -il 'maxcomb'                                <
./IPY0115.prog
./IPY0130.pl
./test_file_shell.sh
./dir_copy_daily_files.sh
./dir_copy_biweekly_files.sh
./condir_and_copy_biweekly.sh
./condir_and_copy_daily.sh
./doi_dnld_files.prog
./IPY0130_old.pl
grep: can't open ./View
grep: can't open for
grep: can't open value_set
grep: can't open Role_id.sql
devr> find . -name '*.*' -print | xargs grep -ilw 'maxcomb'
./IPY0115.prog
./IPY0130.pl
./condir_and_copy_daily.sh
./IPY0130_old.pl
grep: can't open ./View
grep: can't open for
grep: can't open value_set
grep: can't open Role_id.sql

you dont have correct permissions to open the file and grep thru it.

xargs and {}
why is that ?

find with xargs grep that would do..

If you dont want to display the output - that files cant be opened
then use 2>/dev/null with find