To have newline (\n) and other escape characters in bash strings, we can use
$'string' syntax (ANSI-C Quoting).
$'string' expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard. Here is an example.
#!/bin/bash v=$'a\nb' echo "$v" ## echo directly echo $'aa\nbb' echo $'aaa\tbbb'