in reply to Reading a Directory of Files, Searching for Text, Outputting Matches

It seems you are searching for a combination of find, xargs, grep and simple output redirection. No perl needed:

find /some/where/in/the/wild -name '*.txt' -print0 | xargs -0 grep -A3 + 'needle_in_the_haystack' > result.txt

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
  • Comment on Re: Reading a Directory of Files, Searching for Text, Outputting Matches
  • Download Code