Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I write non-ASCII characters using echo?

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
like image 537
flybywire Avatar asked Mar 18 '09 11:03

flybywire


People also ask

How do I type non-ascii characters?

This is easily done on a Windows platform: type the decimal ascii code (on the numeric keypad only) while holding down the ALT key, and the corresponding character is entered. For example, Alt-132 gives you a lowercase "a" with an umlaut.


2 Answers

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

printf '\012' 
like image 165
Nietzche-jou Avatar answered Oct 08 '22 10:10

Nietzche-jou


Use

echo -e "\012"
like image 39
vartec Avatar answered Oct 08 '22 11:10

vartec