bash escape special characters in variable code example
Example 1: bash escape special characters in variable
# Use Shell Parameter Expansion:
foo_esc="${foo@Q}"
Example 2: escape characters in bash
use "\" to use the literal value of the next character (except newline)