As for the elusive part of the question, I had the same problem and resolved with a double sed that can be optimized.
escaped_abc=$(echo $abc | sed "s/\//\\\AAA\//g" | sed "s/AAA//g")
The triple A is used, because otherwise the forward slash after its backslash character never fits in the output, no matter how many backslashes you put in front of it.
source share