How do I write non-ASCII characters using echo?

flybywire picture flybywire · Mar 18, 2009 · Viewed 60.5k times · Source

How do I write non-ASCII characters using echo? Is there an escape sequence, such as \012 or something like that?

I want to append ASCII characters to a file using:

echo ?? >> file

Answer

Nietzche-jou picture Nietzche-jou · Mar 18, 2009

If you care about portability, you'll drop echo and use printf(1):

printf '\012'