LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 05-28-2005, 05:19 AM   #1
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
grep [A-Z] & [a-z] match both upper and lower case.


I am using SuSE Linux 9.2
I noticed that grep ( version 2.5.1 ) matches the lower case letters when using the character range [A-Z].
For example: echo "mc C" | grep '[A-Z][A-Z] [A-Z]'
mc C
Sed behaves the same way.

After setting the environmental variable LC_ALL='C' grep behaves as expected.
My $LANG variable is en_US.UTF-8.

Is this behavior normal, or does it indicate that I have a bad locale setting, or some other goofy configuration setting?

One moral is to use [[:upper:]] and [[:lower:]] in scripts.

Last edited by jschiwal; 05-28-2005 at 05:43 AM.
 
Old 05-28-2005, 06:07 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

As stated in the (grep) manpage: This is a locale issue (see the REGULAR EXPRESSIONS section).

Quote:
To obtain the traditional interpretation of bracket expressions, you can use the C locale by setting the LC_ALL environment variable to the value C.
This is normal behaviour.

Hope this helps.
 
Old 05-28-2005, 06:25 AM   #3
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Original Poster
Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
That is what I did to obtain the behaivior that I was expecting. I read it in the grep man-page. Is it normal to have the LC_ALL='C' setting by default? I believe it was set that way for the root user.

Last edited by jschiwal; 05-28-2005 at 06:27 AM.
 
Old 05-28-2005, 06:38 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi again,

I know that root has the LC_ALL=C setting by default. All my other users also have this setting ('we' are not concerned with other locale settings.).

If I do remember correctly, an english(/american) Suse install will give all users the LC_ALL=C setting. Guess that choosing another language will set a different LC_ALL setting.

I'm currently using suse (old 8.2 version) lfs and slackware. All have LC_ALL set to C for all users. All installs are english, no fiddling with other language settings.

Hope this clears things up a bit.
 
Old 05-28-2005, 06:43 AM   #5
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Original Poster
Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Either I accidentally removed a setting somewhere, or it was reset when I added Russian support.
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upper and lower case problem when mount hardisk UltraSoul Linux - Newbie 1 10-28-2005 08:50 AM
Why are all my upper case files being shown as lower case?? [Kernel 2.6.9-1.667 FC3] t3gah Fedora 4 03-11-2005 04:09 PM
Lower case to upper case letter sudhasmyle Programming 1 12-03-2004 04:15 AM
What's the difference between the upper and lower portions of /proc/meminfo? undercrawler Linux - Hardware 0 03-26-2004 09:57 AM
Apache and upper or lower case. dsiguy Linux - General 3 02-04-2003 11:02 AM


All times are GMT -5. The time now is 01:11 AM.

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