Not too hard to explain... This is like typing hello worl
, hitting the left-arrow key twice, typing d
, and hitting the down-arrow key.
At least, that is how I infer your terminal is interpeting the \b
and \n
codes.
Redirect the output to a file and I bet you get something else entirely. Although you may have to look at the file's bytes to see the difference.
[edit]
To elaborate a bit, this printf
emits a sequence of bytes: hello worl^H^Hd^J
, where ^H
is ASCII character #8 and ^J
is ASCII character #10. What you see on your screen depends on how your terminal interprets those control codes.