how to search string in files??

April 2, 2011 at 01:39:02
Specs: Linux x86_64
Hi, i need help on how to do this:
do a shell script in bash shell that reads 2 parameters in command line, one directory and string. Then it must search for the string in all files starting from the indicated directory (including subfolders) and excluding binary files.
The results should show the complete route of the files that the string has been found, the number of times that the string has been found as well.

Could you please tell me how this can be done? thanks


See More: how to search string in files??

Report •

#1
April 2, 2011 at 03:51:02
use positional parameters to read from command line. eg $1, $2 . to search for files, use find. To search for strings in files, you can use grep.

Report •

#2
April 2, 2011 at 05:36:07
thanks! i have another newbie question, what's a pattern? i mean, instead of searching for a string like my first question, if I was to search for a pattern, will the script be different?

Report •
Related Solutions


Ask Question