Skip to content

Implement -newerXY #307

Closed
Closed

Description

@sylvestre

The upstream manpage states:

-newerXY reference
          Compares the timestamp of the current file with reference.   The
          reference  argument  is  normally the name of a file (and one of
          its timestamps is used for the comparison) but it may also be  a
          string  describing  an  absolute time.  X and Y are placeholders
          for other letters, and these letters select which time belonging
          to how reference is used for the comparison.

          a   The access time of the file reference
          B   The birth time of the file reference
          c   The inode status change time of reference
          m   The modification time of the file reference
          t   reference is interpreted directly as a time
$ find . ! -newermt 'jan 01, 2000' -exec touch -d@1706517278 {} +   
Error: Unrecognized flag: '-newermt'

Activity

  1. hanbings commented on Mar 27, 2024

    @hanbings
    Collaborator

    hi, this issue looks like there hasn't been an update here for a long time, can I give it a try?

  2. cakebaker commented on Mar 27, 2024

    @cakebaker
    Contributor

    @hanbings sure, go ahead :)

  3. hanbings commented on Mar 27, 2024

    @hanbings
    Collaborator

    Thanks.

    Now find . ! -newermt 'jan 01, 2000' -exec touch -d@1706517278 {} + works, and -newerat and -newerct is also available.
    -newerBt is available, but depends on whether the file system supports birthed time / created time.

    Use the following command to better observe the results.

    find . -newermt 'jan 01, 2000'
    find . -newermt 'jan 01, 2000 00:00:00'

    In order to parse this time string, I added a function parse_date_str_to_timestamps() that converts from string to timestamp, then created the corresponding Matcher and compared it with the timestamp of the target file to get the result. I will add relevant test code later.

    Please forgive my code for not looking very good.

  4. linked a pull request that will close this issuefind: Implement `-newerXY` #342on Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions