i have a filter file that i generated by another process. using sed it is made to looks like this:
name [with square]/**
[123-123] [456 456]/**
first of all, the line with two sets of square brackets causes rclone to die in the ass:
rclone -v --include="[123-123] [456 456]/**" copy /blah/ remote:blah/
017/08/05 08:03:51 Failed to load filters: bad glob pattern "[123-123] [456 456]/**" (regexp "(^|/)[123-123] [456 456]/.*$"): error parsing regexp: invalid character class range:3-1`
I can escape the square brackets like
\[123-123\] \[456 456\]/** and it will not fail, and it will match.
Since this is dynamically generated and rclone can’t handle the special characters, even inside quotes, I need to use sed to escape all those characters. is there a list of all the characters i need to find and escape?
I am using this to make it work for now, but I still get the blob errors on some names:
sed -e 's/.*\///' -e 's/[^a-zA-Z 0-9\-]/\\&/g' -e 's/$/\/**/'
is there a better way?