bash: write to a unicode file

Viewed 1556

Aim

I just need to write text to a unicode file but it doesn't seam to be that easy.

The result should be exactly the same as when I open a notepad, enter the following text and save it with unicode encoding:

ä
öü

Attempt

My attempt, to write to an already existing file, looks like this:

(
echo ä
echo öü
)>text.txt

The Result is this:

꓃਍뛃볃਍

1 Answers

One of the probably multiple ways you can do this is with printf or echo -e and using the unicode value of the character. So for example:

$ echo -e '\u00E4'
ä

So you simply can redirect the output wherever you need it:

$ printf  '\u00E4' | tee unicode
ä
Related