Try this:
cd /some/dir && rsync -av --files-from=<(find . -mtime 0 -printf "%p\n") <other stuff>
It uses Process Substitution <( )
to replace the find
command with a named fifo and gives that fifo's name to rsync
to read as what to include in the sync.
Update
In light of Kyle's answer, it definitely appears that --files-from
is more appropriate than --include-from
; although both will work. Answer updated
For -daystart
the manual says:
-- Option: -daystart
Measure times from the beginning of today rather than from 24 hours
ago. So, to list the regular files in your home directory that
were modified yesterday, do
find ~/ -daystart -type f -mtime 1
The '-daystart' option is unlike most other options in that it has
an effect on the way that other tests are performed. The affected
tests are '-amin', '-cmin', '-mmin', '-atime', '-ctime' and
'-mtime'. The '-daystart' option only affects the behaviour of any
tests which appear after it on the command line.
What that means that if you run:
find . -daystart -mtime 1
on the day after the winter changing time (2015-10-25 in Europe this year), that should give you the files last modified between 2015-10-25 01:00
(the first occurrence of that time) and 2015-10-25 23:59:59.999...
.
If run as
find . -daystart -mtime 0
on 2015-10-25, you'd expect it to get you the files modified between 00:00 and 22:59:59, but doing a simple test (with findutils 4.4.2) shows that it returns files modified between the first 01:00 and 23:59:59 (unless run before the time change).
$ find . -printf '%TFT%TT %p\n'
2015-09-25T14:28:25.4868761490 .
2015-10-25T00:02:00.0000000000 ./a
2015-10-25T23:43:00.0000000000 ./c
2015-10-25T12:42:00.0000000000 ./b
$ NO_FAKE_STAT=1 faketime -m '2015-10-25 12:23' find . -daystart -mtime 0
./c
./b
$ NO_FAKE_STAT=1 faketime -m '2015-10-25 00:32' find . -daystart -mtime 0
./a
./b
$ NO_FAKE_STAT=1 faketime -m '2015-10-25 12:23' find . -daystart -mtime 1
./a
In any case the statement So, to list the regular files in your home directory that were modified yesterday above is not always true.
Without -daystart
, the check is for files modified in units of 24 hours. So if run at 12:43
on 2015-10-25, find . -mtime 0
would give you files modified between 2015-10-24 13:43 and now.
A more reliable way to give you the files that were last modified yesterday would be:
find . -newermt 'yesterday 0' ! -newermt 'today 0'
Note that it includes the files that were last modified today at 00:00:00.0000000000 and not the ones at that time yesterday. Unfortunately there's no -oldermt
predicate.
Note that zsh
's age
function to use in globs like:
$ autoload age # in ~/.zshrc
$ ls -ld -- *(age,yesterday,)
has similar issues.
Best Answer
Yes,
-mtime 14
means exactly 14. See the top of that section in the GNUfind
manual (labelled "TESTS") where it says "Numeric arguments can be specified as [...]":Note that "less than" means "strictly less than", so
-mtime -14
means "last modified at the current time of day, 13 days ago or less" and-mtime +14
means "last modified at the current time of day, 15 days ago or more".