Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have bunch of files on the remote server.

I'm not interested in most of them, except for .pl files.

I want to get a copy of these on my local computer.

What is the best way to do this (at the same try preserving its path)?

I'm thinking somewhere along the lines of:

find . -name "*.pl" | xargs scp localuser@localip

Sadly doesn't do the trick. Anyone have better ideas?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

$rsync -av --prune-empty-dirs --include-from=filter user@remotesource/ target/

$cat filter

+ *.pl
+ */
- *

edit: typo

share|improve this answer
    
After a bit of modification, this also works. Now to decide which is the winner... decisions. –  denormalizer Oct 13 '10 at 22:42
    
After checking the results, i found the rsync method copied all the .pl files while the find method (for some reason) skipped a substantial number of .pl files. So i have to award the answer to Rosco. –  denormalizer Oct 13 '10 at 22:53
    
Even though i chose this as the answer, i find it rather inconvenient to create the extra filter file. I would have leant towards the find method if it did copy all the files. –  denormalizer Oct 13 '10 at 22:56
add comment

Maybe this?

{
  find -type d -printf "mkdir %p\n" ;
  find -name "*.pl" -printf "put %p %p\n" ;      
} | sftp localuser@localip
share|improve this answer
    
Testing this first. Worked. Yay! –  denormalizer Oct 13 '10 at 22:22
    
Sorry i can't upvote. i needz more reputation –  denormalizer Oct 13 '10 at 22:56
    
@superspace You should mark the answer as "accepted" if it resolved your problem. –  jscott Jul 23 '12 at 17:10
add comment

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.