fd icon indicating copy to clipboard operation
fd copied to clipboard

How to find files which haven't changed within a specified period of time

Open bernardassan opened this issue 3 years ago • 2 comments

What version of fd are you using? [ fd 8.3.2 ]

I know that fd -tf --changed-within=4weeks . prints files in the current directory that have changed within 4week. how do i find those that haven't changed within 4week

bernardassan avatar Mar 13 '22 23:03 bernardassan

If you found --changed-within, why didn't you find --change-before? (serious question, I'm always looking for ways to improve documentation)

        --changed-before <date|dur>
            Filter results based on the file modification time. The argument
            can be provided as a specific point in time (YYYY-MM-DD HH:MM:SS)
            or as a duration (10h, 1d, 35min). '--change-older-than' or
            '--older' can be used as aliases.
            Examples:
                --changed-before '2018-10-27 10:00:00'
                --change-older-than 2weeks
                --older 2018-10-27

sharkdp avatar Mar 14 '22 07:03 sharkdp

@sharkdp Thanks , i saw --changed-before also but I just couldn't see how that was the inverse of --changed-within. I suggest this be mentioned in the man docs like

--changed-within date|duration
              Filter  results  based on the file modification time.  Files with modification times greater than the argument will be
              returned.  The argument can be provided as a duration (10h, 1d, 35min) or as a specific point in time in  either  full
              RFC3339  format  with  time zone, or as a date or datetime in the local time zone (YYYY-MM-DD or YYYY-MM-DD HH:MM:SS).
              --change-newer-than can be used as an alias for --changed-within .
              NOTE: --changed-before is the inverse of --changed-within .ie to get files that haven't changed within a specified 
              date|duration --changed-before is used.

              Examples:
                --changed-within 2weeks  #files that have changed within 2 week
                --change-newer-than "2018-10-27 10:00:00"  #files that have been changed after 2018-10-27 10:00:00

--changed-before date|duration
              Filter results based on the file modification time.  Files with modification times less than the argument will be  re‐
              turned.   The  argument  can  be provided as a duration (10h, 1d, 35min) or as a specific point in time in either full
              RFC3339 format with time zone, or as a date or datetime in the local time zone (YYYY-MM-DD  or  YYYY-MM-DD  HH:MM:SS).
              --change-older-than can be used as an alias for --changed-before.
              NOTE: --changed-within is the inverse of --changed-before .ie to get files/dir that have changed after a specified 
              date|duration --changed-within is used.

              Examples:
                --changed-before "2018-10-27 10:00:00" #files that where changed before 2018-10-27 10:00:00
                --change-older-than 2weeks  #changes that were made before 2weeks ago

Or That another alias be made for either --change-within which will be called --changed-after or one be made for --changed-before which will be called --not-changed-within. I feel the confusion is coming from the fact that --changed-within and --changed-before sound like two completely different options so if my understanding of --changed-within and --changed-before are right then either of these new aliases will make the inverse relationship between the two options obvious so the NOTE: in the man pages suggested won't be required anymore , only the new alias would be mentioned which is self explanatory.

bernardassan avatar Mar 14 '22 15:03 bernardassan