[Wylug-discuss] Copy files by date
Smylers
Smylers at stripey.com
Wed Jan 25 10:01:19 UTC 2012
linux at sh2515.plus.com writes:
> I am having trouble with some macs. I need to copy lots of files in
> subdirectories - temporarily everyday - without cron from server a
> server b from work created yesterday.
Are you copying them to the same destination as the previous days files?
If so then rsync would do this for you; it automatically skips any files
which already exist in the destination.
> find . -iname "*.txt" -mtime -1 | xargs -I % cp -r % ~/test/
>
> The find on our macs don't have -daystart argument so I am finding it
> inaccurate. Anyway to copy files by yesterdays date manually starting
> script everyday?
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 ...
-newermt says to compare the modification time of files with the time
specified, and running date with the %F format just gives the date
without a time, so is interpreted as the start of today. But you still
need a way of passing yesterday's date to the date command.
Smylers
More information about the Wylug-discuss
mailing list