Is it possible with SCP to only copy files that match a certain date?
Is it possible to have SCP filter the files that it copies by date, e.g., if you wanted to copy all files that were created on 12/29 and ignore the others?
Solution 1:
You can't do this directly with scp
. The unix way is to combine tools, you want the find
command.
Here is an example of searching for a file with a given date:
touch --date "2007-01-01" start
touch --date "2008-01-01" end
find -type f -newer start -not -newer end
I took this example from here: http://www.cyberciti.biz/faq/linux-unix-osxfind-files-by-date/
To feed this into scp you could do this:
find -type f -newer start -not -newer end -exec scp {} dest: \;
This will call scp once per file, which could be slow because it needs to bring up the connection each time. If you only have a handful of files and there are no spaces in the names you can do this:
scp `find -type f -newer start -not -newer end` dest: