[Wylug-discuss] Copy files by date

Smylers Smylers at stripey.com
Wed Jan 25 11:04:04 UTC 2012


Earlier I wrote:

> If Macs have the -newerXY option (which FreeBSD seems to), then you
> can easily get files modified since the start of today with:
> 
>   $ find . -iname "*.txt" -newermt $(date +%F) | xargs ...
> 
> But you still need a way of passing yesterday's date to the date
> command.

A Perl one-liner can do this pretty easily, making the complete command:

 $ find . -iname "*.txt" -newermt $(perl -MDateTime -E 'print DateTime->now->truncate(to => "day")->subtract(days => 1)') | xargs ...

(That requires the DateTime module, which you may need to install
first.)

Smylers



More information about the Wylug-discuss mailing list