Sounds like you have a specified place for the nightly logs. To get a listing of the ".log" files, adapt this code which lists the ".pl" files in my C:/temp directory...

#!/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";
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".

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.