Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I run an ls -ltr on myserver.org:/some/path/dir:

-rw-r--r-- 1 devops   devops   20727251 Mar 16 08:02 herp1.derp
-rw-r--r-- 1 devops   devops   24542012 Mar 16 08:03 herp2.derp
-rw-r--r-- 1 stduser devops    7716282 Mar 16 08:31 herp3.derp
-rw-r--r-- 1 stduser devops 1490729406 Apr 20 08:04 herp4.derp
-rw-r--r-- 1 stduser devops 1489656380 Apr 20 08:04 herp5.berp
-rw-r--r-- 1 stduser devops 1489960585 Apr 20 08:04 herp6.derp
-rw-r--r-- 1 stduser devops 1492748611 Apr 20 08:04 herp7.berp

I'm looking for a way to use scp in conjunction with a file pattern that will only return *.berp files that were last touched/modified on Apr 20. Usually my scp syntax is:

scp someUser@myserver.org:/some/path/dir/* .

But I want the file pattern /some/path/dir/* to only pull down Apr 20 *.berp files. Any ideas? Thanks in advance!

share|improve this question

1 Answer 1

As you are trying to fetch from a remote server via SSH, you could do it like this:

ssh someUser@myserver.org "cd /some/path/dir/; tar cz \`find . -name '*.berp' -daystart -mtime -5 -a -mtime +3\`" | tar xvz

You may have to play with the mtime values to get the exact date you want.

share|improve this answer

Your Answer

 
discard

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.