<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding Log files that have been created on the current day.  On Linux mach in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35779#M8871</link>
    <description>Try this to see whether it finds the files as you need:&lt;BR /&gt;
&lt;BR /&gt;
filename foo pipe "find &amp;amp;logdir -maxdepth 1 -type f  -name '*.log' -mtime -1 -exec ls -l '{}' \;" ;&lt;BR /&gt;
&lt;BR /&gt;
data _null_ ;&lt;BR /&gt;
infile foo ;&lt;BR /&gt;
input ;&lt;BR /&gt;
put _infile_ ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
The -MTIME option can be a bit tricky, you made need to specify -2 in place of -1 to get all the expected files, check the man page on find for details.</description>
    <pubDate>Mon, 28 Mar 2011 16:12:45 GMT</pubDate>
    <dc:creator>TimB_SAS</dc:creator>
    <dc:date>2011-03-28T16:12:45Z</dc:date>
    <item>
      <title>Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35774#M8866</link>
      <description>HI,&lt;BR /&gt;
&lt;BR /&gt;
I have in my program the following that works just fine, but I want it to do something more:&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe "ls -1 &amp;amp;logdir | grep .log";&lt;BR /&gt;
&lt;BR /&gt;
where &amp;amp;logdir is assigned as the log directory that I want to search.  I want to find only those log files that were created today.  This is what I tried:&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe "ls -1 &amp;amp;logdir | grep '&amp;amp;mdate' ";&lt;BR /&gt;
&lt;BR /&gt;
where &amp;amp;mydate is equal to say - Mar 22    &lt;BR /&gt;
&lt;BR /&gt;
Of course this doesn't work!!  I could use any suggestions.&lt;BR /&gt;
&lt;BR /&gt;
From the command line I can use the following:&lt;BR /&gt;
&lt;BR /&gt;
ls -l /cpspb/prod/log/mar11/ | grep "$mydate"   , if the variable mydate has been assigned first.&lt;BR /&gt;
&lt;BR /&gt;
Thanks, Nancy</description>
      <pubDate>Tue, 22 Mar 2011 19:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35774#M8866</guid>
      <dc:creator>SASHunter</dc:creator>
      <dc:date>2011-03-22T19:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35775#M8867</link>
      <description>instead of&lt;BR /&gt;
 filename indata pipe "ls -1 &amp;amp;logdir | grep '&amp;amp;mdate'";&lt;BR /&gt;
try&lt;BR /&gt;
 filename indata pipe "ls -1 &amp;amp;logdir | grep ""&amp;amp;mdate"" ";</description>
      <pubDate>Tue, 22 Mar 2011 22:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35775#M8867</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-22T22:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35776#M8868</link>
      <description>I changed the program to have the following:&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe "ls -l &amp;amp;logdir | grep ""&amp;amp;newdate"" ";&lt;BR /&gt;
&lt;BR /&gt;
where &amp;amp;logdir  and &amp;amp;newdate resolve to the following:&lt;BR /&gt;
&lt;BR /&gt;
34         filename indata&lt;BR /&gt;
SYMBOLGEN:  Macro variable LOGDIR resolves to /cpspb/prod/log/mar11/&lt;BR /&gt;
SYMBOLGEN:  Macro variable NEWDATE resolves to Mar 23&lt;BR /&gt;
34       !                 pipe "ls -l &amp;amp;logdir | grep ""&amp;amp;newdate"" ";&lt;BR /&gt;
35         &lt;BR /&gt;
&lt;BR /&gt;
But this still is not working.  This is the error I get.  Like it can't read the files that it found.  &lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile INDATA is:&lt;BR /&gt;
      Pipe command="ls -l /cpspb/prod/log/mar11/ | grep "Mar 23" "&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Physical file does not exist, /cpspb/prod/log/mar11/-rw-rw-r-- 1 cpsmod &lt;BR /&gt;
       cpspb    2581 Mar 23 14:38 blaisechgdaypi.log.&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7&lt;BR /&gt;
&lt;FF&gt;3                                The SAS System  14:38 Wednesday, March 23,&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
1         -rw-rw-r-- 1 cpsmod cpspb    2581 Mar 23 14:38 blaisechgdaypi.log 65&lt;BR /&gt;
lname=  linectr=0&lt;BR /&gt;
f2r=-rw-rw-r-- 1 cpsmod cpspb    2581 Mar 23 14:38 blaisechgdaypi.log&lt;BR /&gt;
file2read=/cpspb/prod/log/mar11/-rw-rw-r-- 1 cpsmod cpspb    2581 Mar 23 14:38 b&lt;BR /&gt;
laisechgdaypi.log done=0 _ERROR_=1 _N_=1&lt;BR /&gt;
NOTE: 1 record was read from the infile INDATA.&lt;BR /&gt;
      The minimum record length was 65.&lt;BR /&gt;
      The maximum record length was 65.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If I do this same command directly on the command line, I get the following:&lt;BR /&gt;
&lt;BR /&gt;
/home/hunte022&amp;gt; ls -l /cpspb/prod/log/mar11/ | grep 'Mar 23'&lt;BR /&gt;
-rw-rw-r-- 1 cpsmod cpspb    2581 Mar 23 14:38 blaisechgdaypi.log&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Does anyone see what I am doing wrong?&lt;BR /&gt;
&lt;BR /&gt;
Thanks, Nancy&lt;/FF&gt;</description>
      <pubDate>Wed, 23 Mar 2011 18:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35776#M8868</guid>
      <dc:creator>SASHunter</dc:creator>
      <dc:date>2011-03-23T18:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35777#M8869</link>
      <description>Move your "filter logic" (grep component) to operate as part of the SAS DATA step.  &lt;BR /&gt;
&lt;BR /&gt;
And, with that suggestion, have you at least verified the SAS FILENAME and associate specifications work correctly without the "grep" component?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 23 Mar 2011 19:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35777#M8869</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-23T19:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35778#M8870</link>
      <description>I am still struggling with this code!!&lt;BR /&gt;
&lt;BR /&gt;
I'm not sure what you mean by 'Move your "filter logic" (grep component) to operate as part of the SAS DATA step.'&lt;BR /&gt;
&lt;BR /&gt;
The grep command is part of the filename statement.  As the following:&lt;BR /&gt;
filename indata pipe "ls -lt --full-time &amp;amp;logdir | grep &amp;amp;testmdate ";&lt;BR /&gt;
&lt;BR /&gt;
38         filename indata&lt;BR /&gt;
SYMBOLGEN:  Macro variable LOGDIR resolves to /cpspb/prod/log/mar11/&lt;BR /&gt;
SYMBOLGEN:  Macro variable TESTMDATE resolves to 2011-03-28&lt;BR /&gt;
38       !                 pipe "ls -lt --full-time &amp;amp;logdir | grep &amp;amp;testmdate ";&lt;BR /&gt;
&lt;BR /&gt;
The file is definitely in the log directory, but I get this ERROR:&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The infile INDATA is:&lt;BR /&gt;
      &lt;BR /&gt;
      Pipe command="ls -lt --full-time /cpspb/prod/log/mar11/ | grep 2011-03-28 &lt;BR /&gt;
      "&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Physical file does not exist, /cpspb/prod/log/mar11/-rw-rw-r-- 1 cpsmod  &lt;BR /&gt;
        cpspb    6237 2011-03-28 08:10:35.000000000 -0400 &lt;BR /&gt;
       err_list_SASLOG_Summarizer_28MAR11.rtf.&lt;BR /&gt;
RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7&lt;BR /&gt;
1         -rw-rw-r-- 1 cpsmod   cpspb    6237 2011-03-28 08:10:35.000000000 -040&lt;BR /&gt;
      71  0 err_list_SASLOG_Summarizer_28MAR11.rtf 110&lt;BR /&gt;
lname=  linectr=0&lt;BR /&gt;
f2r=-rw-rw-r-- 1 cpsmod   cpspb    6237 2011-03-28 08:10:35.000000000 -0400 err_&lt;BR /&gt;
list_SASLOG_Summarizer_28MAR11.rtf&lt;BR /&gt;
&lt;BR /&gt;
/-------------------------------------------------------------------------------------------------------------------------/&lt;BR /&gt;
If I do the following at the prompt in Linux, I get what I am expecting.  It finds the three files that have today's date associated with them.&lt;BR /&gt;
&lt;BR /&gt;
 /home/hunte022&amp;gt; ls -t1 --full-time /cpspb/prod/log/mar11 | grep '2011-03-28'&lt;BR /&gt;
-rw-rw-r-- 1 cpsmod   cpspb    6237 2011-03-28 08:10:35.000000000 -0400 err_list_SASLOG_Summarizer_28MAR11.rtf&lt;BR /&gt;
-rw-rw-r-- 1 cpsmod   cpspb  191973 2011-03-28 08:10:35.000000000 -0400 error_checker.log&lt;BR /&gt;
-rw-rw-r-- 1 cpsmod   cpspb    4084 2011-03-28 08:10:35.000000000 -0400 misclist_SASLOG_Summarizer_28MAR11.rtf&lt;BR /&gt;
/home/hunte022&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
What can I be doing wrong?&lt;BR /&gt;
&lt;BR /&gt;
Thanks, Nancy</description>
      <pubDate>Mon, 28 Mar 2011 12:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35778#M8870</guid>
      <dc:creator>SASHunter</dc:creator>
      <dc:date>2011-03-28T12:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35779#M8871</link>
      <description>Try this to see whether it finds the files as you need:&lt;BR /&gt;
&lt;BR /&gt;
filename foo pipe "find &amp;amp;logdir -maxdepth 1 -type f  -name '*.log' -mtime -1 -exec ls -l '{}' \;" ;&lt;BR /&gt;
&lt;BR /&gt;
data _null_ ;&lt;BR /&gt;
infile foo ;&lt;BR /&gt;
input ;&lt;BR /&gt;
put _infile_ ;&lt;BR /&gt;
run ;&lt;BR /&gt;
&lt;BR /&gt;
The -MTIME option can be a bit tricky, you made need to specify -2 in place of -1 to get all the expected files, check the man page on find for details.</description>
      <pubDate>Mon, 28 Mar 2011 16:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35779#M8871</guid>
      <dc:creator>TimB_SAS</dc:creator>
      <dc:date>2011-03-28T16:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35780#M8872</link>
      <description>You need "ls -l" (the letter l) for displaying the date, but not for extracting the filename.&lt;BR /&gt;
&lt;BR /&gt;
So maybe this helps:&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe "ls -1 &amp;amp;logdir | grep '&amp;amp;mdate' | cut -c52-";&lt;BR /&gt;
&lt;BR /&gt;
"cut" display's from columns52 and more, so this is only the filename.</description>
      <pubDate>Mon, 28 Mar 2011 16:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35780#M8872</guid>
      <dc:creator>RalphGöstenmeier</dc:creator>
      <dc:date>2011-03-28T16:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35781#M8873</link>
      <description>Thanks for every ones help.&lt;BR /&gt;
&lt;BR /&gt;
I have finally figured out what I needed to change in the program.&lt;BR /&gt;
&lt;BR /&gt;
I have the FILENAME statement that now looks like this:&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe "ls -lt --full-time &amp;amp;logdir | grep .log | grep &amp;amp;testmdate ";&lt;BR /&gt;
&lt;BR /&gt;
where it resolves to:&lt;BR /&gt;
21         filename indata&lt;BR /&gt;
SYMBOLGEN:  Macro variable LOGDIR resolves to /cpspb/prod/log/mar11/&lt;BR /&gt;
SYMBOLGEN:  Macro variable TESTMDATE resolves to 2011-03-28&lt;BR /&gt;
21       !                 pipe "ls -lt --full-time &amp;amp;logdir | grep .log | grep&lt;BR /&gt;
21       ! &amp;amp;testmdate ";&lt;BR /&gt;
&lt;BR /&gt;
And inside the dataset, I have the following that I had to change in the INPUT statement:&lt;BR /&gt;
&lt;BR /&gt;
30         data mylist;&lt;BR /&gt;
31         &lt;BR /&gt;
32            length lname $55;&lt;BR /&gt;
33         &lt;BR /&gt;
34            INFILE indata lrecl=200 pad;&lt;BR /&gt;
35            retain linectr 0;&lt;BR /&gt;
36         &lt;BR /&gt;
37            input @73 f2r $80.;       * Start reading at this character on the&lt;BR /&gt;
37       !  line;&lt;BR /&gt;
38         &lt;BR /&gt;
39            file2read="&amp;amp;logdir"||f2r;&lt;BR /&gt;
SYMBOLGEN:  Macro variable LOGDIR resolves to /cpspb/prod/log/mar11/&lt;BR /&gt;
40         &lt;BR /&gt;
41            infile dummy filevar=file2read filename=lname end=done&lt;BR /&gt;
42                                     lrecl=200 truncover;&lt;BR /&gt;
43         &lt;BR /&gt;
44         run;&lt;BR /&gt;
&lt;BR /&gt;
--------------------------------------------------------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
This now does the 'ls' command and then does the two greps to narrow my search.&lt;BR /&gt;
&lt;BR /&gt;
And I start reading only at position 73 to find the file name.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the other examples.  I will test them also.  &lt;BR /&gt;
&lt;BR /&gt;
Nancy</description>
      <pubDate>Mon, 28 Mar 2011 17:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35781#M8873</guid>
      <dc:creator>SASHunter</dc:creator>
      <dc:date>2011-03-28T17:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Finding Log files that have been created on the current day.  On Linux mach</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35782#M8874</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
Just a little addition to this post:&lt;BR /&gt;
&lt;BR /&gt;
I tried Ralph's recommendation also.  This worked, when adding the 'cut' at the end of the FILENAME statement.&lt;BR /&gt;
&lt;BR /&gt;
filename indata pipe &lt;BR /&gt;
    "ls -lt --full-time &amp;amp;logdir | grep .log | grep &amp;amp;testmdate | cut -c73-";&lt;BR /&gt;
&lt;BR /&gt;
and changing the INPUT statement back to what I had.&lt;BR /&gt;
from:&lt;BR /&gt;
INPUT @73 f2r $80.;&lt;BR /&gt;
to:&lt;BR /&gt;
INPUT f2r $80.; &lt;BR /&gt;
&lt;BR /&gt;
-------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;
The FILENAME resolves to:&lt;BR /&gt;
21         filename indata pipe&lt;BR /&gt;
SYMBOLGEN:  Macro variable LOGDIR resolves to /cpspb/prod/log/mar11/&lt;BR /&gt;
SYMBOLGEN:  Macro variable TESTMDATE resolves to 2011-03-30&lt;BR /&gt;
22             "ls -lt --full-time &amp;amp;logdir | grep .log | grep &amp;amp;testmdate | cut&lt;BR /&gt;
22       ! -c73-";&lt;BR /&gt;
&lt;BR /&gt;
and it finds the one file that has today's date in it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for the suggestions.&lt;BR /&gt;
&lt;BR /&gt;
Nancy</description>
      <pubDate>Wed, 30 Mar 2011 12:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Finding-Log-files-that-have-been-created-on-the-current-day-On/m-p/35782#M8874</guid>
      <dc:creator>SASHunter</dc:creator>
      <dc:date>2011-03-30T12:47:47Z</dc:date>
    </item>
  </channel>
</rss>

