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 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.

share|improve this question
add comment

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.

share|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
add comment

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/ .
share|improve this answer
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.