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.