Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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:

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:
share|improve this answer
It's easy when you copy files from client to server, but what about the other way around? – Petr Peller Mar 30 '14 at 18:14
@PetrPeller To copy in the opposite direction you can do this: scp dest:`ssh dest find -type f -newer start -not -newer end` . – Edward Betts Mar 31 '14 at 11:11
Nice trick, thanks ;) – Petr Peller Mar 31 '14 at 12:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.