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. |
Hi,
As stated in the (grep) manpage: This is a locale issue (see the REGULAR EXPRESSIONS section). Quote:
Hope this helps. |
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.
|
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. |
Either I accidentally removed a setting somewhere, or it was reset when I added Russian support.
|
All times are GMT -5. The time now is 05:59 PM. |