http://www.perlmonks.org?node_id=184215
Category: Utility Scripts
Author/Contact Info Thomas Klausner domm AT zsi.at
Description: I just cannot remember how to run find and grep together. After reading the FM once too often, I wrote this small wrapper..

Pass it a pseudo-regex (to match the files) and another one to look for in all files.

Example:
% dgrep .pm foo Will look for "foo" in all files ending in ".pm" in the current and lower directories.

Edited: ~Tue Jul 23 15:24:49 2002 (GMT), by footpad:
Added <code> tags to the code.

#!/usr/bin/perl -w
$|=1;
my ($findin,$grepfor)=@ARGV;
my $in=qq(find -name '*$findin' -exec grep -Hn '$grepfor' {} \\;);
print `$in`;