Professional Web Applications Themes

how to find files less than a day old? - FreeBSD

Hello, I'm trying to write a script to concatenate a bunch of files. Basically I want to grab a bunch of files out of a directory that are less than an hour or so old and put them in one file. This is what I am using so far: find . -mtime -1 -type f | xargs cat > temp.txt However, this only grabs files that are less than a day old, so I get some files returned that I don't want. I tried using -0.5 instead of -1 and it didn't work. How can I accomplish this? Thanks /Brian...

  1. #1

    Default how to find files less than a day old?

    Hello,
    I'm trying to write a script to concatenate a bunch of files. Basically I
    want to grab a bunch of files out of a directory that are less than an
    hour or so old and put them in one file.

    This is what I am using so far:

    find . -mtime -1 -type f | xargs cat > temp.txt

    However, this only grabs files that are less than a day old, so I get some
    files returned that I don't want. I tried using -0.5 instead of -1 and it
    didn't work. How can I accomplish this?

    Thanks

    /Brian
    Brian Guest

  2. #2

    Default Re: how to find files less than a day old?

    On Tue, 29 Mar 2005 13:02:37 -0600 (CST), Brian John
    <com> wrote: 


    find . -mtime -1h -type f ....

    man find


    --
    Noel Jones
    Noel Guest

  3. #3

    Default Re: how to find files less than a day old?

    > On Tue, 29 Mar 2005 13:02:37 -0600 (CST), Brian John [/ref]
    Basically I [/ref]
    some [/ref]
    and it 
    >
    >
    > find . -mtime -1h -type f ....
    >
    > man find
    >
    >
    > --
    > Noel Jones
    > _______________________________________________
    > org mailing list
    > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > To unsubscribe, send any mail to[/ref]
    "org" 
    I read the man page and didn't see that. It doesn't appear to work on the
    box that I am ssh-ing to. Sorry, I should have mentioned that it is not a
    FreeBSD box that I am connected to. I think it may be a Solaris 9 box.
    Is there any way to get this to work in Solaris?

    Thanks

    /Brian
    Brian Guest

  4. #4

    Default Re: how to find files less than a day old?

    On Tue, 29 Mar 2005 14:11:45 -0600 (CST), Brian John
    <com> wrote: [/ref]
    > Basically I [/ref]
    > some [/ref]
    > and it 
    > >
    > >
    > > find . -mtime -1h -type f ....
    > >
    > > man find
    > >
    > >
    > > --
    > > Noel Jones
    > > _______________________________________________
    > > org mailing list
    > > http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    > > To unsubscribe, send any mail to[/ref]
    > "org" 
    > I read the man page and didn't see that. It doesn't appear to work on the
    > box that I am ssh-ing to. Sorry, I should have mentioned that it is not a
    > FreeBSD box that I am connected to. I think it may be a Solaris 9 box.
    > Is there any way to get this to work in Solaris?
    >[/ref]

    Maybe the solaris find command supports the -newer option. I think
    -newer is more widely supported, and likely to be available on
    Solaris.

    If necessary, you could then create a reference file using touch with
    the proper time stamp on it. You can do this automatically within a
    script, using the date command to figure out the current time. You
    can calculate the time one hour ago by using a command something like
    TZ={your timezone + 1} date


    --
    Noel Jones
    Noel Guest

  5. #5

    Default Re: how to find files less than a day old?

    > On Tue, 29 Mar 2005 14:11:45 -0600 (CST), Brian John 
    > > Basically I [/ref][/ref]
    than an 
    > > some 
    > > and it 
    > > "org" 
    > > I read the man page and didn't see that. It doesn't appear to work on[/ref][/ref]
    the [/ref]
    not a 
    >
    > Maybe the solaris find command supports the -newer option. I think
    > -newer is more widely supported, and likely to be available on
    > Solaris.
    >
    > If necessary, you could then create a reference file using touch with
    > the proper time stamp on it. You can do this automatically within a
    > script, using the date command to figure out the current time. You
    > can calculate the time one hour ago by using a command something like
    > TZ={your timezone 1} date
    >
    >
    > --
    > Noel Jones
    >[/ref]
    Is there a way that I could do this without using find? I basically just
    need a listing of files to pipe to cat. Is there any easier way to do
    this? If there isn't, could you explain in more explicit email how to
    this?

    /Brian
    Brian Guest

  6. #6

    Default Re: how to find files less than a day old?

    It doesn't appear to work on my FreeBSD box, either. What does work is this:
    find /var/log -newerct '1 hour ago' -exec cat {} >> /var/tmp/filename \;

    Jerry
    http://www.syslog.org
     


    Jerry Guest

  7. #7

    Default Re: how to find files less than a day old?

    > > > FreeBSD box that I am connected to. I think it may be a Solaris 9 box. 
    > >
    > > Maybe the solaris find command supports the -newer option. I think
    > > -newer is more widely supported, and likely to be available on
    > > Solaris.
    > >
    > > If necessary, you could then create a reference file using touch with
    > > the proper time stamp on it. You can do this automatically within a
    > > script, using the date command to figure out the current time. You
    > > can calculate the time one hour ago by using a command something like
    > > TZ={your timezone 1} date
    > >
    > >
    > > --
    > > Noel Jones
    > >[/ref]
    > Is there a way that I could do this without using find? I basically just
    > need a listing of files to pipe to cat. Is there any easier way to do
    > this? If there isn't, could you explain in more explicit email how to
    > this?
    >
    > /Brian
    >[/ref]

    Here's some commands that should be pretty portable.

    touch `TZ=CST7CDT date "+%m%d%H%M"` /path/to/file
    find . -newer /path/to/file -type f | xargs cat > tmp.txt

    Adjust the value of TZ to give the proper time in your locale. I'm in
    Central Standard Time, which is normally expressed as CST6CDT, so I
    added one to get "CST7CDT". This creates a file stamped exactly one
    hour ago that find can use as a reference.

    An alternative would be to write something in perl or your programming
    language of choice.

    HTH...

    --
    Noel Jones
    Noel Guest

  8. #8

    Default Re: how to find files less than a day old?

    > > > > FreeBSD box that I am connected to. I think it may be a Solaris 9
    box. 
    > > Is there a way that I could do this without using find? I basically just
    > > need a listing of files to pipe to cat. Is there any easier way to do
    > > this? If there isn't, could you explain in more explicit email how to
    > > this?
    > >
    > > /Brian
    > >[/ref]
    >
    > Here's some commands that should be pretty portable.
    >
    > touch `TZ=CST7CDT date " %m%d%H%M"` /path/to/file
    > find . -newer /path/to/file -type f | xargs cat > tmp.txt
    >
    > Adjust the value of TZ to give the proper time in your locale. I'm in
    > Central Standard Time, which is normally expressed as CST6CDT, so I
    > added one to get "CST7CDT". This creates a file stamped exactly one
    > hour ago that find can use as a reference.
    >
    > An alternative would be to write something in perl or your programming
    > language of choice.
    >
    > HTH...
    >
    > --
    > Noel Jones
    >[/ref]
    Thanks! That worked.

    /Brian
    Brian Guest

Similar Threads

  1. help: can't find external files
    By nike in forum Macromedia Director Lingo
    Replies: 3
    Last Post: December 4th, 04:19 PM
  2. find files
    By e.group in forum Sun Solaris
    Replies: 18
    Last Post: September 19th, 11:54 AM
  3. Find Files By Date
    By Nicholas Dronen in forum PERL Miscellaneous
    Replies: 5
    Last Post: August 9th, 02:36 AM
  4. where could i find .fla files?
    By !.........................! in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: July 15th, 11:28 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139