I needed to restore some files from an archive on UNIX, but only the files of a particular date-range were needed. It took a few moments to find and figure out how I could easily extract files older than a particular date, or files from a particular date-range. This is how:
- Create a perimeter file, like so:
touch -t yyyymmddHHMM marker_date - List files older than the marker_date:
find . -type f ! -newer marker_date -ls
Of course, instead of `-ls’ parameter (to list), you can use `-print’ and a pipe to xargs to, for example, delete the selected files, etc.
Likewise, for a range of dates:
- Create the perimeter files:
touch -t yyyymmddHHMM range_start
touch -t yyyymmddHHMM range_end - List the files between the range dates:
find . -type f -newer range_start ! -newer range_end -ls
Thanks, that was very helpful!
Nice!!!!!!
Hi,
That’s very helpful
I would like to know if I could translate your post in French (with a backlink for sure)
Thanks by advance
Best Regards
Pierre-Yves
Hi Pierre! And sorry for the slow response… I need to tend to my blog more often!
Yes, absolutely! And a backlink would be great!
It was very HelpFul.. Thanks
simple, elegant, working solution. Made my day.