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?

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

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

$cat filter

+ *.pl
+ */
- *

edit: typo

link|improve this answer
After a bit of modification, this also works. Now to decide which is the winner... decisions. – superspace 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. – superspace 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. – superspace Oct 13 '10 at 22:56
feedback

Maybe this?

{
  find -type d -printf "mkdir %p\n" ;
  find -name "*.pl" -printf "put %p %p\n" ;      
} | sftp localuser@localip
link|improve this answer
Testing this first. Worked. Yay! – superspace Oct 13 '10 at 22:22
Sorry i can't upvote. i needz more reputation – superspace Oct 13 '10 at 22:56
feedback

Your Answer

 
or
required, but never shown

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