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!

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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