0

If you read all from post How to copy all files from a directory to a remote directory using scp? you will find there is no answer that actually (as in ALWAYS) works, even though a (non)answer has a big green check mark.

I have the following "solution" but am asking whether someone knows a less cumbersome method.

  1. Use "scp -r" to copy local_directory to remote_directory -- note that local_directory will be placed within remote_directory which is NOT desired but is easily fixed...
  2. On remote machine create links within remote_directory to the files within remote_directory/local_directory -- I recommend the "find" command executing the "ln" command to accomplish this.
  3. On remote machine use "rm -r remote_directory/local_directory" to remove unwanted directory.
1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented May 1 at 14:59

1 Answer 1

0

This is similar to How to copy a folder recursively in an idempotent way using cp? but works only for the newer scp that uses SFTP to transfer its files:

scp -rp /path/to/src/. remoteHost:/path/to/dst

The trailing /. on the source is the key to its success.

  1. Where dst does not exist, the source path is backtracked and the name src is used
  2. Where dst does already exist, the source directory . and its contents are copied to it. But since . means this directory, no additional subdirectory is created

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.