Perl
Simple Perl Code (Input REGEX, Search through files by that REGEX)
CEOinIRVINE
2011. 4. 20. 07:34
#!/usr/bin/perl
#perl-grep.pl
my $regex = shift @ARGV;
print "Regex is [$regex]\n";
while ( <> )
{
print if m/$regex/;
}
[root@"+":/tmp]$ perl perl-grep.pl new *.pl
Regex is [new]
my $new_name = "$dirname/$basename";
rename ($old_name, $new_name)
or warn "Can't rename '$old_name' to '$new_name': $!";
[root@"+":/tmp]$