Include/Exclude Pattern for rsync ONLY the latest file of the src dir

Matt McCutchen matt at mattmccutchen.net
Tue Oct 28 14:45:12 GMT 2008


On Tue, 2008-10-28 at 14:58 +0100, Stefan Mosleitner wrote:
> Is it possible to selcect a particular source directory and filter/select
> ONLY the latest file in this directory for rsync?

Selection of the latest file is not built into rsync, but it can be
scripted easily:

rsync OPTION... SRC/"$(ls -t1 SRC | head -n 1)" DEST/

Or you can do something like --include="$(ls -t1 SRC | head -n 1)"
--exclude='*' if you prefer.

Matt



More information about the rsync mailing list