title: Getting printf to print escaped backslashes
body: <p>Because I need to be able to print lines that may start with what would otherwise be treated as an option by <code>echo</code>, I devised a shell function that uses <code>printf</code> to print to the terminal. If I needed to print newlines or tabs, I learned that I have to use <code>%b</code> instead of <code>%s</code> because <code>printf "%s" "\n"</code> would print the literal <code>\n</code> to the screen. The function is defined as this:</p>
  
  <pre><code>my_echo () {
      printf "%b" "${1}"
  }
  </code></pre>
  
  <p>Just recently, I found out that trying to print escaped escape sequences is more complicated than it normally is. The command <code>printf "%b" "\\n"</code> will print a newline. To print the literal for a newline, I have to use <code>printf "%b" "\\\n"</code>, but using this requires recoding all of my other functions and scripts to handle this. Is there some way to get <code>printf "%b" "\\n"</code> or whatever to come out as the escaped escape sequence?</p>