How to exclude file when using scp command recursively

You can exclude files when using the scp command recursively by using the --exclude option of the rsync utility, which is used by scp to transfer files and directories.

For example, to exclude files with the .log extension while copying all files and directories from the local directory /path/to/source to the remote directory /path/to/destination:

 
$ scp -r --exclude="*.log" /path/to/source username@remote-host:/path/to/destination

You can specify multiple exclude patterns by repeating the --exclude option. Note that the exclude patterns use wildcard characters and follow the syntax of the rsync utility.

Leave a Comment