i want to find the file list on a date

April 7, 2011 at 22:15:34
Specs: unix, 1gb
being in the root directory , i want to find out the files list edited on the particular date from all child directories.

See More: i want to find the file list on a date

Report •

#1
April 8, 2011 at 13:27:19
This script uses the find and ls command to list files edited on a given date - what I call the file list date. In the ls -l command fields 6, 7, and 8 and the month, day, year respectively

Keep in mind that the old style ls command keeps the time in field 8 for 6 months and the year after that. That's what all that colon checking in the awk script is all about. You have to make sure you are checking the right year.

I think it's correct, but I'd do more checking

!/bin/ksh

# cd <to your directory - root or otherwise>

# file list date
DD=19
YEAR=2010
MONTH="Aug"

# current year and month
CYEAR=$(date '+%Y')
CMONTH=$(date '+%m')

find . -follow -type f -print |xargs ls -l|
awk ' {

     mypivyear="'"$CYEAR"'"
     # change character string to integer
     mymonth="'"$CMONTH"'" + 0

    retval=index($8, ":")
    # greater than zero if colon exists
    if( retval > 0)
      { # is it the current year or the current year minus 1
      if(mymonth == 1 || mymonth == 2 || mymonth = 3 || mymonth == 4  || mymonth == 5 || mymonth == 6)
        {
        if($6 == "Jul" || $6 == "Aug" || $6 == "Sep" || $6 == "Oct" || $6 == "Nov" || $6 == "Dec" )
            pivyear=mypivyear - 1
         else
            pivyear=mypivyear
        }
        else
            pivyear=mypivyear
      }
     else
         pivyear=$8 # use the year with no changes


   if($6 == "'"$MONTH"'" && $7 == "'"$DD"'" && pivyear == "'"$YEAR"'")
      print $9
}'


Report •
Related Solutions


Ask Question