Linux – Exclude Certain Files and Folders while Copying

When we copy a certain folder to a remote machine using scp, we might want to exclude some sub folders or files. The following command worked for me in those kind of situations.

scp !(bin) root@target-machine:/opt/your-folder-name/  

In this case, it copies everything except the bin folder from the current working directory to /opt/your-folder-name/ folder in target-machine

Advertisements