Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-12-2008, 10:49 AM   #1
LQ Newbie
Registered: Jul 2008
Posts: 4

Rep: Reputation: 0
Shell won't recognise foreign characters

Hi everyone,

I'm having a nightmare trying to write a shell script that, among other things, changes to a directory that has foreign characters in its name.

From Ubuntu's terminal, I can type:

$ cd Ontology/Top/World/Franšais/

and it moves me to my Franšais directory without a problem.

In my shell script, however, when I have:




# Move to the top level of the ontology
cd $dir

# Find all of the categories at the top level of the ontology
ls > directories.tmp

I get the error message:

cd: 8: can't cd to Ontology/Top/World/Fran�ais/

Why won't my script let me use the š character when I can do it without a problem from the terminal?

Help please!
Old 07-12-2008, 01:18 PM   #2
LQ Guru
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I'm not a shell script master when it comes to using locales, but would you need to export the LC_ALL value - did you check that it's actually set?

EDIT: but if LC_ALL is set to that value when you run the script, it should be in use anyway if I'm not mistaken. Just as a guess, does the charset/keymap of your console (which sh uses; not necessarily the same that for example gnome-terminal uses) contain the glyph you're using?

Last edited by b0uncer; 07-12-2008 at 01:23 PM.
Old 07-12-2008, 02:07 PM   #3
Senior Member
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
or you can use a wildcard
Old 07-13-2008, 03:23 AM   #4
Mr. C.
Senior Member
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 61
I had no trouble with the script (I added a mkdir to the script to create the directories for me):

$ cat


mkdir -p $dir

# Move to the top level of the ontology
cd $dir

# Find all of the categories at the top level of the ontology
ls > directories.tmp

$ ./

$ LC_ALL="fr_FR.UTF-8" ls -R




My sh is bash-based, perhaps yours is Bourne-shell based, or behaves in compatibility mode with called by /bin/sh. Try changing #!/bin/sh to #!/bin/bash
Old 07-14-2008, 03:52 AM   #5
LQ Newbie
Registered: Jul 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Tried that, but no success...What did help was to change the foreign characters to character symbols! Not so readable but it worked...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ntfs-3g cannot access files with foreign characters dissociative Slackware 3 05-11-2008 10:26 PM
Accented Characters and other "foreign language" Characters Mark_in_Hollywood LQ Suggestions & Feedback 2 04-30-2007 06:10 PM
Centericq foreign characters messed up dlublink Linux - Software 2 02-24-2005 10:14 AM
Foreign Characters in Fedora RC2 bluemak Linux - Newbie 1 08-30-2004 08:37 AM
gnome-terminal and foreign characters b0uncer Linux - Software 0 05-06-2004 01:03 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration