A directory is opened, then all files in that directory are read and filtered by grep{}. Note that a directory within that directory is just a special kind of "file", but filtering on things that end in ".log" probably eliminates them, but be aware that it might not, that case you need a file test, like "-f".#!/usr/bin/perl -w use strict; my $path = "C:/temp"; opendir (my $dirhandle, $path) || die "cannot open dir $path"; my @perl_files = grep {/.pl$/} readdir $dirhandle; print "@perl_files";
In your case, I would think that: $path="/pptai/nightly_db/data_loader_logs"; along with "grep{/.log$/}" would yield all log files. Note that if you want to do a "file test" like -e, -f, etc, you will need to test the complete file path name, "$path/$specific_file". Above @perl_files only contains the file names, not the full paths. Oh, also enclose "$path/$specific_file" in quotes otherwise Perl will think that you are doing division!
In reply to Re: Doubt regarding find and grep command
by Marshall
in thread Doubt regarding find and grep command
by siddheshsawant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |