Supposed local folder as below:
/test/subfolder
/test/subfolder/file1.txt
/test/subfolder/page1.htm
/test/subfolder/page2.htm
/test/.hiddenfolder
/test/./hidenfolder/file2
How to exclude .hiddenfolder to be transfer when executing "scp -r test user@ip:/"?
How to include *.htm files only and transfer them to corresponding subfolder on remote server?
Any other commands can do this job more easily?
I don't think scp alone can do what you ask. You should investigate rsync instead.
I use it for backups with a filter to exclude files with names that don't work on NTFS volumes
you can also pass it the name of a file that contains the files to exclude (
--exclude-from=file
)Edit: Here's a sample command line that works for your example:
If you already have pre-shared ssh keys, you could first create all the remote directories in the following way:
I think that's about what you're looking for.