D2 = `echo $ D | sed 's /\./\\\\./ g'`
echo $ D2
Think of shells checking a line every time it is executed. So echo $ D1, which has escape sequences in it, has the value escapes applied to the value when the string is parsed before echo sees it. The solution escapes even more.
Getting the right vertices on nested shell operations can make you live in interesting moments.
source share