View Full Version : Bash special characters

June 11th, 2010, 06:59 PM
I'm getting a spanish random words generator and I'm having trouble with special characters: I get


instead of


which is weird, as I can, for instance, acces to the image folders typing

:~$ cd Imágenes

Can anybody help me with this?

Thank you!

PS: I'm also having trouble with the been program as nothing sounds when I type

beep (speakers are on ;))

June 11th, 2010, 11:21 PM
Sounds like that word generator outputs words in a specific character encoding, ignoring your current one. Is that a program you got from the ubuntu repositories?

June 12th, 2010, 12:01 AM
Hello geirha and thank you for answering. The program is, in fact, a bash script which uses for the output head and tail:

l=$(cat diccionario);n=$(( 100+(`od -An -N2 -i /dev/urandom` )%(49308-0+1) ));cat diccionario | head -n$n | tail -n1

The words are in a clear text file (diccionario).

It might be important to know that I've tried the bash script in the mobile terminal of the iphone and there is no problem with the special characters of the words listed (there are problems whith the characters when using the echo command for other outputs, though).

Thank you again!

June 12th, 2010, 12:23 AM
OK, it was simple... Sorry for any inconvenience... I had to add another encodig (ISO...)

June 12th, 2010, 12:54 AM
Better to just convert it to your current locale. Try

n=$(wc -l < "$dict")
r=$(( $(od -An -N3 -i /dev/urandom) % n + 1 )
sed -n "$r{p;q;}" "$dict" | iconv -f iso-8859-15

June 12th, 2010, 10:21 AM
Thank you! I'm going to try.

June 12th, 2010, 07:14 PM
I've realized that the problem was on editting the dictionary file: I took that one from /usr/share/myspell and edited it. If I copy the words and paste them in a new document, there is no problem any more.