Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Find files in directories

    So i have directories that store logs, 1 directorie for each day, with the name like this :


    and for each directorie we have the logs, inside them lives the logs for that day, and every log have this name pattern :


    and every file have 100 mb

    now i presente the env i can tell the problem i have is my script that i will show on the bottom will show you how i do things right now but, question is if i have a leap in days or hours or anything between my $startdate and $enddate value that i use to search for the files that i want to see in the directorie logs, then a problem comes because we can have logs that came like this :


    and think on this what if i want to see logs from 2012_07_02 ??? and this can happen because if a sensor dont collect enough traffic for the 100 mb then he goona leaps the end date until it reachs the 100mb
    but, for this i'm thinking or if i can search for the last know file before the date i search ? that would do the trick but i dont know how to do it right now i have this :

    for dir in `ls | sort | sed -n "/$startdate/,/$enddate/p"` ; do
      if [ `ls $dir | wc -l` -gt 0 ] ; then
        ls $dir
        rmdir $dir

    soo with that said can anyone give me a hand , i know some people use find like:
    find ${DIR} \ (-name $startdate and $enddate) -ctime > /tmp/list.txt

    i just dont know how to combine that in my script in the right way.
    Last edited by drd0spt; 11-09-2012 at 03:54 PM. Reason: better explanation

  2. #2
    Hello and welcome!

    Okay, I've read your post, went away, came back and read it again..and I still don't get what you want. Can you explain it better? I think there might be a language barrier, but focus on this: In your scenario, what are the directories, and what are the files? Show an example of your directory structure and also state a very clear example of what you are looking for.

    Example dir structure:
    Are you wanting to search inside (the contents of) files for dates, or are you searching file names containing date strings in them? Or are you searching the names of directories for date strings in them? Or some combination, or something else?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts