Hmm ich wurde das ganze anders herum machen:catweasel schrieb:Hi!
Code:find ~ -type f | perl -ne 'print if /test/'
Was muss ich hier noch einfügen, damit Perl nicht mit den Dateinamen arbeitet, sondern die Datein selbst durchsucht?
find ~ -type f -name "*test*"
find . -maxdepth 1 -type f | perl -ne 'if (/test/) { open(F, $_) || die($!); while (<F>) { print; } } close(F);'
grep -r test *
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
no warnings 'File::Find';
find(\&wanted, ".");
sub wanted
{
my $file = $File::Find::name;
if (-f $file)
{
open(FH, "<$file");
while(<FH>)
{
if ($_ =~ m/test/)
{
print "$file\n";
}
}
close(FH);
}
}
find2perl
Das ist mir doch zu lang.}-Tux-{ schrieb:}-Tux-{Code:find . -maxdepth 1 -type f | perl -ne 'if (/test/) { open(F, $_) || die($!); while (<F>) { print; } } close(F);'
Ich hätte etwas für die Kommandozeile gebraucht.abgdf schrieb:Code:#!/usr/bin/perl use warnings; use strict; use File::Find; no warnings 'File::Find'; find(\&wanted, "."); sub wanted { my $file = $File::Find::name; if (-f $file) { open(FH, "<$file"); while(<FH>) { if ($_ =~ m/test/) { print "$file\n"; } } close(FH); } }