0

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.

EEAA
  • 109,363
  • 18
  • 175
  • 245

2 Answers2

0

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.

spikeheap
  • 113
  • 4
0

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/ .
polynomial
  • 4,016
  • 14
  • 24