4 of 14 added 18 characters in body; deleted 1 character in body

There are a lot of ways to do this. The most portable two that I know of are sed and od - they're both POSIX.

printf '\n\r\b\t\033[01;31m' | sed -n l

It does like... read style escapes - C-style.



od is a little more configurable...

printf '\n\r\b\t\033[01;31m' |
od -v -w12 -t c -t a -A n

 \n  \r  \b  \t 033   [   0   1   ;   3   1   m
 nl  cr  bs  ht esc   [   0   1   ;   3   1   m

If you wanna know what all of those options do you can look in man od, but I specify I want two types of escapes - the -t c backslash escapes and the -t a named characters.

And here's a little shell function that will portably print out the octal values of each byte in its arguments:

proctal() (LC_ALL=C
    for a do while 
    printf %o\\n "'${a:?}"
    do a=${a#?}; done
    done )2>/dev/null