I have a folderA remotely which has 2 subfolders folderB and folderC.I have to search for my

file where it is located in the 2 subfolders(folderB and folderC) and should copy it.

Is it possible with rsync and a script like thing.

link|improve this question
feedback

2 Answers

You could always use find over ssh:

scp user@hostname:`ssh user@hostname "find folderA -name \"targetFile\" "` .

This opens up two SSH connections, so you'll be prompted for the password twice unless you've set up unprotected key-files.

link|improve this answer
It doesn't work if file name including spaces. – quanta Sep 28 '11 at 16:34
It will if you escape your spaces with a '\' character – spikeheap Sep 29 '11 at 8:20
It is not a concrete filename. How do you escape it from your above command? – quanta Sep 29 '11 at 8:23
feedback

Sure, using rsync just exclude everything, then only include the name of the file you want:

$ rsync --exclude="*" --include="filename" -e ssh user@remote:path/to/folderA/ .
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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