0

I have encountered a small issue with SCP(and also rsync). I need to copy certain files from server A(running SunOS 5.8) to server B(running SunOS 5.10).

First, I get the list of files(several hundred) via ssh and find

FILES=`ssh user@remote find ./ -name "*.sh" -o -name "*.cbs" -print`
scp -r user@remote:"$FILES" /u01/appl/somedir/ 

My problem is, I want to copy files with relative paths, e.g. product/11/ora/clean.sh creating also the directory structure(in result having /u01/appl/somedir/product/11/ora/clean.sh ). Currently I am only able to download the file and no directories are created. As you can see I used -r flag in scp.

Thank you for advices

Mike Nagy
  • 137
  • 1
  • 11
  • Try [unix.SE](http://unix.stackexchange.com/), not here. Your problem is "recursive" only works when copying directories by name, not for copying files by name. – mr.spuratic Apr 02 '13 at 15:49

1 Answers1

0

I think an easier way to do this would be to tar the files and then send them...

FILES=`tar cvf files.tgz `find ./ -name "*.sh" -print``
scp user@remote:/home/user $FILES

This keeps all directory structure.

bsmoo
  • 949
  • 4
  • 10
  • 23