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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-28-2005, 05:19 AM
|
#1
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
|
05-28-2005, 06:07 AM
|
#2
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,868
|
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.
|
|
|
|
05-28-2005, 06:25 AM
|
#3
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
Original Poster
|
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.
|
|
|
|
05-28-2005, 06:38 AM
|
#4
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,868
|
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.
|
|
|
|
05-28-2005, 06:43 AM
|
#5
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
Original Poster
|
Either I accidentally removed a setting somewhere, or it was reset when I added Russian support.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:08 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|