Rsync does not exclude files or folders with "[" or "]" in file/folder name
The manual page says
--exclude-from=FILE read exclude patterns from FILE
Note the word patterns. The exclude list does not consist of mere file names, but patterns. Try backslashes:
test \[folder4\]
From the rsync man page, "INCLUDE/EXCLUDE PATTERN RULES" section:
- a '
[
' introduces a character class, such as[a-z]
or[[:alpha:]]
.- in a wildcard pattern, a backslash can be used to escape a wildcard character, but it is matched literally when no wildcards are present. This means that there is an extra level of backslash removal when a pattern contains wildcard characters compared to a pattern that has none. e.g. if you add a wildcard to "
foo\bar
" (which matches the backslash) you would need to use "foo\\bar*
" to avoid the "\b
" becoming just "b
".
This means that [file4]
will be treated as a pattern that matches any of the single characters "f", "i", "l", "e", or "4". To get the square-brackets to be treated literally, you need to escape them, like: test \[file4\].txt
.