Answer the question
In order to leave comments, you need to log in
Array of subfolders - how?
I take an array of folders, from which I then pull out a bunch of files that I work with.
opendir(DIR, "/log");
my @folders=grep{!/\./i}
readdir(DIR);
closedir(DIR);
And then it turned out that in the /log directory, I not only need to pull out all the files from subfolders, but from subfolders. Those. /log/blablabla/blabla/files
At the same time, I cannot specify the absolute path further /log - it can change, but the script should work.
I can not figure out how to write it correctly - I recently began to comprehend perl.
Answer the question
In order to leave comments, you need to log in
Made. Made it easier.
opendir(DIR, "log");
my @logs=grep{!/^\.+?/i} readdir(DIR);
closedir(DIR);
foreach my $sub (@logs){
opendir(DIR, 'log'.$sub) or die "FATAL EPIC ERROR";
my @sub_logs = grep{!/^\.+?/i} readdir(DIR);
print "LOG: $sub\n";
foreach my $subsub (@sub_logs)
{
print "\t$subsub";
}
close DIR;
}
I have an article in my publication about processing archives from webcams with pure bash, maybe it will help you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question