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
In reply to Re: Reading a Directory of Files, Searching for Text, Outputting Matches
by afoken
in thread Reading a Directory of Files, Searching for Text, Outputting Matches
by NorthShore44
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |