Copying files and dirs on remote server while excluding some of them

Posted by llaskin on Stack Overflow See other posts from Stack Overflow or by llaskin
Published on 2010-06-18T16:40:19Z Indexed on 2010/06/18 16:43 UTC
Read the original article Hit count: 179

Filed under:
|

Server 1 is connected to Server 2 via SSH.

We know this: I can execute a command such as

" ssh server2 "cp -rv /var/www /tmp" "

which will copy the entire /var/www dir to /tmp. However inside of /var/www we have the following structure(sample LS output below)

$ ls /web1 /web2 /web3 file1.php file2.php file3.php

How can I execute a cp command that will exclude /web1, /web3, file1.php and file3.php (obviously just copying web2 and file2 is not an option since there are significantly more files than just 6)

© Stack Overflow or respective owner

Related posts about linux

Related posts about ssh