0

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?

denormalizer
  • 491
  • 2
  • 5
  • 15

2 Answers2

1

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

$cat filter

+ *.pl
+ */
- *

edit: typo

Rosco
  • 455
  • 3
  • 6
  • 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
0

Maybe this?

{
  find -type d -printf "mkdir %p\n" ;
  find -name "*.pl" -printf "put %p %p\n" ;      
} | sftp localuser@localip
LatinSuD
  • 901
  • 1
  • 8
  • 17