Script to search Multiple Stirng

February 18, 2011 at 03:17:40
Specs: Windows XP
Hi ,
I have Multiple strings placed in input file and that needs to be serached in various files on unix. I want to create a script which does this task and provide me with output file conatining list of the files having the input strings.

See More: Script to search Multiple Stirng

Report •

February 18, 2011 at 18:12:03
In the script below, the strfile.txt file contains the multiple strings - one per line. The directories I choose to search are ./sct15 and ./sct22. You can change that to whaever you wish. The names of just the files are redirected to outputfile.txt:


rm -f outputfile.txt
# output only file names that have the strings
while read line
   find ./sct15 ./sct22 -exec grep -l "$line" {} \; >> outputfile.txt
done < strfile.txt

Report •
Related Solutions

Ask Question