S
S
Sargass2012-07-16 14:22:14
Perl
Sargass, 2012-07-16 14:22:14

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

3 answer(s)
R
RomanoO, 2012-07-16
@RomanoO

First link from google

S
Sargass, 2012-07-17
@Sargass

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; }

N
Nikolai Turnaviotov, 2012-07-21
@foxmuldercp

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 question

Ask a Question

731 491 924 answers to any question