Results 1 to 4 of 4

Thread: Question: generating date ranges when using find utility

  1. #1
    Join Date
    Apr 2008
    Beans
    3

    Question: generating date ranges when using find utility

    Hello,

    Using the -atime -mtime or -ctime tests in the find utility returns information about files that were accessed, modified or changed N 24 hour periods ago. Does anyone know how to use time utilities to generate arguments to these tests that specify particular dates? One could use a calender and a calculator to compute the number of days between the desired date and the current time. But, section 6.6 'Relative Times in Date Strings' in the find info pages explain a scheme of expressions for specifying relative times. The problem is that the expressions are valid arguments to the date utility, which returns date strings, not numbers of 24 hour periods between times.

    Thanks,
    M.Reich

  2. #2
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    1,702
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Question: generating date ranges when using find utility

    Use the "-newerXY" specification. For instance:
    Code:
    # finds all file modified since March 20
    find . -newermt 20130320 -ls
    Variants allow you to compare the timestamps of the file to the timestamp of a reference file (find -neweram foo.bar) will find all files accessed ('a') since the modification ('m') of foo.bar .

    If you need older files, then use "not newer", you can even combine several tests:
    Code:
    # find all files changed between March 10 and March 20. 
    find . -newermt 20130310 -a -not -newermt 20130320 -ls

  3. #3
    Join Date
    Apr 2008
    Beans
    3

    Re: Question: generating date ranges when using find utility

    Hello,

    Thanks for the response. I thought all -newer variations compared timestamps, missed -newerXt.
    Incidentally, your location looks water logged.

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    1,702
    Distro
    Kubuntu 12.10 Quantal Quetzal

    Re: Question: generating date ranges when using find utility

    Quote Originally Posted by mreich View Post
    Incidentally, your location looks water logged.
    No it's not, you are looking at inaccurate maps

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
  •