Take the 2-minute tour ×

What is the proper way of inserting a copyright symbol © and a pound sterling symbol £ into a bash script.

I am using nano as my editor and am running Debian Squeeze.

If I copy and paste the symbol from windows, it works but it seems to paste hidden characters that nano cannot display and it makes it hard to edit code in the shell script then.

So for example I want to be able to do this:-

text2="© John Doe"
share|improve this question
check your locale and encoding settings, since this isn't an issue on my machine (fully utf-8). –  lynxlynxlynx Jul 4 '12 at 20:11
@lynxlynxlynx how do i do this ?? (Linux newbie) –  general exception Jul 4 '12 at 20:11
locale must print strings with utf-8 in them. Ok, some other compatible encoding would work too, but this is the simplest. –  lynxlynxlynx Jul 4 '12 at 20:14
then you need to set these bash variables (export LC_ALL=en_US.utf-8). While you could do it manually, I'm sure debian has an init.d/conf.d/profile.d/rc.d script in /etc to set it globally on system startup. All the available values on your system can be listed with locale -a. –  lynxlynxlynx Jul 4 '12 at 20:19
Apparently it's set in /etc/environment in debian or at least was in 2010. –  lynxlynxlynx Jul 4 '12 at 20:24

3 Answers 3

up vote 1 down vote accepted

It seems you are using a locale that doesn't support these symbols (in the olden days it could have also been a bad font). Since you are using UTF-8 characters (default on windows), you also need to be in a UTF-8 aware environment on linux. You can check that with the locale command:

$ locale

So my system is fine, but yours had the default, ASCII C locale set. These are simple bash variables, so you could export them individually or override them all (by setting LC_ALL). However, that would only affect the current shell, so you need to make it part of shell initialisation to work everytime automatically.

This is usually done through profile scripts in /etc globally, but .bash_profile or .bashrc would work just as well. In your version of Debian the locale is stored in /etc/default/locale and you can get the list of available choices with locale -a, eg.:

$ locale -a

Pick one with an utf8 suffix. If you need other locales (for example japanese), they can be generated with localedef/locale-gen (comes with glibc or as a separate package).

share|improve this answer

If you're having problems with entering the symbols in nano, use escape syntax. You can use iconv to convert it to the output encoding corresponding to the current locale:

text2=$'\xa9 John Doe'
iconv -f latin1 <<< $text
iconv -f latin1 <<< $text2

or the same in utf8:

text2=$'\xc2\xa9 John Doe'
iconv -f utf-8 <<< $text
iconv -f utf-8 <<< $text2
share|improve this answer

Better just use (C) for copyright, you want it to be always readable in other locales and not a defense for violation.

The display looks like

text2=" ohn Doe"

in my test terminal.

share|improve this answer
And what about the £ ? –  general exception Jul 5 '12 at 9:09
I would say (GBP) if I want to sell it to locations that cannot display the £ sign. –  pizza Jul 5 '12 at 9:20

Your Answer


