Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2005
    Posts
    92

    Unanswered: extracting files arrivng today and those arrived y'day

    Hi All.,

    1 ssssss C2052EX 15 Mar 30 19:01
    1 aaaaa C2052EX 15 Apr 3 10:12
    1 ccccc C2052EX 15 Apr 4 09:28


    i have files arriving like above.
    i am using the following to extract files arriving today ( say apr4)


    todaydat=`date | cut -c5-10`
    find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mmin +200 | grep
    "$todaydat" | awk -F" " {'print $9'}


    now i am trying to extract files arriving today ( say apr 4) and those arrived y'day ( say apr 3)
    can anyone please give me any suggestions.


    thanks
    pavi

  2. #2
    Join Date
    Feb 2004
    Location
    Los Angeles, CA
    Posts
    28

    Try the mtime argument

    Use the -mtime (Modified Time) argument in the find statement.

    Code:
     todaydat=`date | cut -c5-10` 
    find DIR_PATH/START.*.*.*.ctl* -mtime 1 -exec ls -ltr {} \; -mmin +200 | grep 
    "$todaydat" | awk -F" " {'print $9'}
    1 = Yesterday, 2 the day before etc...
    +1 = all days yesterday and before.

  3. #3
    Join Date
    Oct 2005
    Posts
    92

    extracting files arrived today and yesterday

    can you please give me the mtime arguement..

    thanks
    pavi

  4. #4
    Join Date
    Oct 2005
    Posts
    92

    extracting files arrived today and yesterday

    Hello.,

    i am doing this;

    todaydat=`date | cut -c5-10`

    find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mtime -2 -mmin +200 | grep "$todaydat" | awk -F" " {'print $9'}

    This is giving me only the files arrived today ( Apr 4) but i am also looking for files arrived Apr 4 and Apr 3rd.

    can you please suggest me;

    thanks
    pavi

  5. #5
    Join Date
    Oct 2005
    Posts
    92

    extracting files arrived today and yesterday

    Hello

    i am using these ( from man pages in Unix)
    yesterdaydat=date -d "yesterday" | cut -c5-10
    Apr 3

    todaydat=date | cut -c5-10
    Apr 4

    now i am trying to use the output of both the above commands to extract the files arrived today and yesterday. can you please give me a suggestion;

    find DIR_PATH/START.*.*.*.ctl* -exec ls -ltr {} \; -mmin +200 | grep
    "$todaydat" | awk -F" " {'print $9'}

    thanks a bunch
    pavi

  6. #6
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    mtime -2
    will find last 48 hours which could include the day before yesterday e.g.
    Code:
    # ls -l
    total 5
    drwxr-xr-x   2 root root 288 Apr  5 10:34 .
    drwxrwxrwt  20 root root 864 Apr  5 10:31 ..
    -rw-r--r--   1 root root   0 Apr  3 03:59 f0
    -rw-r--r--   1 root root   0 Apr  3 23:09 f1
    -rw-r--r--   1 root root   0 Apr  3 23:59 f2
    -rw-r--r--   1 root root   0 Apr  4 00:00 f3
    -rw-r--r--   1 root root   0 Apr  4 12:00 f4
    -rw-r--r--   1 root root   0 Apr  4 23:59 f5
    -rw-r--r--   1 root root   0 Apr  5 00:00 f6
    -rw-r--r--   1 root root   0 Apr  5 03:59 f7
    -rw-r--r--   1 root root   0 Apr  5 10:20 f8
    -rwxr-xr-x   1 root root 224 Apr  5 10:29 t1
    # date
    Wed Apr  5 10:48:12 SAST 2006
    # find . -mtime -2 -mmin +200 -ls
    150012    0 -rw-r--r--   1 root     root            0 Apr  3 23:09 ./f1
    150054    0 -rw-r--r--   1 root     root            0 Apr  3 23:59 ./f2
    150062    0 -rw-r--r--   1 root     root            0 Apr  4 00:00 ./f3
    171447    0 -rw-r--r--   1 root     root            0 Apr  4 12:00 ./f4
    171448    0 -rw-r--r--   1 root     root            0 Apr  4 23:59 ./f5
    171449    0 -rw-r--r--   1 root     root            0 Apr  5 00:00 ./f6
    171456    0 -rw-r--r--   1 root     root            0 Apr  5 03:59 ./f7
    Try this instead (and you don't need grep "$todaydat")
    Code:
    # touch -t 200604032359.59 /tmp/reffile.$$
    # find . -newer /tmp/reffile.$$ -mmin +200 -exec echo {} \;
    ./f3
    ./f4
    ./f5
    ./f6
    ./f7
    # rm /tmp/reffile.$$
    OR
    Code:
    # yd=$(date -d "yesterday"|cut -c 5-10)
    # td=$(date |cut -c 5-10)
    # find . -mtime -2 -mmin +200 -ls | egrep "$yd|$td" | awk '{print $11}'
    ./f3
    ./f4
    ./f5
    ./f6
    ./f7

Posting Permissions

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