How do I write non-ASCII characters using echo?


Question

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
1
28
5/11/2013 5:04:41 PM

Accepted Answer

Use

echo -e "\012"
26
5/11/2013 7:31:23 AM

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

printf '\012'

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon