I want to sync all *.sh files in exactly one sub directory. I tried this cmd but all files in a directory are synced instead of only particular file types.
rsync -vr -n --include="*.sh" --exclude="*/*/" --prune-empty-dirs /source /target
I also tried adding a filter like
--filter="+ *.sh"
but this did not change the result. Another filter
rsync -vr -n --include="*.sh" --filter="-! *.sh" --exclude="*/*/" --prune-empty-dirs
gives me an empty list. If I exclude "*" I also exclude "*.sh"... What is wrong? Thanks!
The depth should be one - the name of the subdirectory is not known. For example,
home/subdirectory1/subsubdirectory/subsubsubdirectory/file.sh
home/subdirectory1/file1.sh
home/subdirectory2/file2.sh
home/subdirectory3/file
In the above example rsync
should start in home, sync directory hierarchy and only the files file1.sh
and file2.sh
-r
option if you don't want to descend into all subdirectories (you said "in one subdirectory")? Wouldrsync -v /source/*.sh /target
not do the trick?*.sh
files. The word special has a particular meaning (devices, pipes, etc.). On the other hand,*.sh
files aren't special; they just have three characters on the end of the filename.