[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep : problem with locale
From: |
Sylvain |
Subject: |
grep : problem with locale |
Date: |
Thu, 20 Apr 2006 10:14:45 +0200 |
Hi !
There is a little problem with the man page :
Finally, certain named classes of characters are predefined within bracket
expressions, as follows. Their names are self explanatory, and they are
[:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:],
[:punct:], [:space:], [:upper:], and [:xdigit:]. For example, [[:alnum:]]
means [0-9A-Za-z], except the latter form depends upon the C locale and the
ASCII character encoding, whereas the former is independent of locale and
character set. (Note that the brackets in these class names are part of the
symbolic names, and must be included in addition to the brackets delimiting
the bracket list.) Most metacharacters lose their special meaning inside
lists. To include a literal ] place it first in the list. Similarly, to
include a literal ^ place it anywhere but first. Finally, to include a
literal - place it last.
The interessant sentence is : "whereas the former is independent of locale
and character set"
-----------
export address@hidden
export address@hidden
echo "é" | egrep "[[:alpha:]]"
=> é
echo "é" | egrep "[a-zA-Z]"
=> é
echo "é" | egrep "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]"
-----------
export LANG=en_us
export LC_ALL=en_us
echo "é" | egrep "[[:alpha:]]"
echo "é" | egrep "[a-zA-Z]"
echo "é" | egrep "[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]"
-----------
So the [[:alpha:]] class is locale dependant contrary of the doc say.. No ?
Have a nice day
Sylvain,
from France so sorry for my bad english :)
- grep : problem with locale,
Sylvain <=