Hello,
I'm facing a problem with a command that works on Linux but not on Unix (Solaris 10).
I want to find files and scp then to another server. This command is:
find /path -type f -exec scp {} root@node000C76211737:{} \;
All the files are found correctly but it looks like the last "{}" is not replaces by the file name and all the files are actually copied to file {} in the root's home dir.
Hm works even on AIX and it's find will be more limited than GNU's find or on Solaris I bet. Maybe try a workaround with xargs?
Edit: I jsut noticed that scp told me it transfered the files but I can't find them by no means. Maybe I would need a workaround in that case on AIX too. Just as info that my 1st message is not correct it seems.
The string `{}' is replaced by the current file name being
processed everywhere it occurs in the arguments to the command, not just in
arguments where it is alone, as in some versions of find.
Might be that that's your problem. Try running it as
$ find test -type f -exec scp ${SCP_OPTS} -r {} root@192.168.0.1:/root/. \;
Well..., try it and see what happens - it'll default to the home directory, but I prefer to put a path in front of the filenames, so you can do something like this:
find ./test -type f | xargs -i scp '{}' root@192.168.0.1:~/'{}'
____
Even this will be enough ( defaulting to remote server's home dir ) ...
find ./test -type f | xargs -i scp '{}' root@192.168.0.1:
find test -type f | xargs -i scp '{}' root@192.168.0.1:'{}'
find ./test -type f | xargs -i scp '{}' root@192.168.0.1:~/'{}'
There is a difference between those two commands. The 1st just use the full path of the found file and copies it to the same path.
/etc/myapp/test.txt --> /etc/myapp/test.txt
The second will copy the full path to the home dir.
/etc/myapp/test.txt --> ~/etc/myapp/test.txt