Reputation: 79
I am new to perl, and I am currently stuck on this problem.
I was trying something like
grep -rl "keyword" /.;
#where does the filenames get stored? let's say in $_?
#foreach valid file, do something
from some website I found, but it doesn't seem to work? Help please, Thanks!!
Upvotes: 0
Views: 1908
Reputation: 20838
How about
ls *keyword*
If you trying to do this within perl
@files = glob("*keyword*");
for $file (@files)
{
print "$file\n";
}
Note that grep
in perl is a core function, but it has nothing to do with regular expressions. It is a more like SQL where
; it filters an array to a subarray by applying a function (which may or may not be a regex) to each element.
If glob expressions are not good enough, you can do
@files = grep /(fun[kK]y_)keyword?/ glob("*");
Upvotes: 2