Questions about using scp

1

  1. In a previous post, I asked a question about simply right-click copy and paste in Nautilus sometimes cannot handle files with special characters in their names under Ubuntu.

    Later I found that scp seems to be able to solve this problem. Perhaps cp also can, but I haven't been able to tried yet.

    So I was wondering in what situations scp and cp will fail to copy files/directories?

  2. If I want to copy all contents under directory "source" to be under another one "destination", my command will be:

    scp -r source/* user@server:destination
    

    I was wondering if I want to copy just some not all subdiretories/files, i.e. excluding other subdirectories and files, under "source" to be under "destination", how to write a command?

Thanks!

Tim

Posted 2011-02-12T19:23:18.777

Reputation: 12 647

If you have really complex copy/move needs, you may want to strongly consider looking at rsync instead of scp. It is far more flexible and usable in differing use-cases. – Zoredache – 2011-02-12T22:04:49.523

Answers

1

As per the scp man pages:

scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] -S program] [[user@]host1:]file1 [...] [[user@]host2:]file2

You can keep specifying files at the end there.

http://www.computerhope.com/unix/scp.htm

Nitrodist

Posted 2011-02-12T19:23:18.777

Reputation: 1 488

0

I'd use find to get all files in the current directory and lower:

find . > list_of_files

Then edit that list_of_files file to just include what you want to copy. Then scp them:

for i in `cat list_of_files` ; do scp $i user@server:dest ; done

maco

Posted 2011-02-12T19:23:18.777

Reputation: 755