Adam Thornton writes:
> On Mon, 2003-06-16 at 10:55, McKown, John wrote:
> > As best as I can tell, the following sed script should change all the upper
> > case to lower case. It is not working (SLES7)
> >
> > echo "XX" | sed 'y/[A-Z]/[a-z]/'
> >
> > What am I doing wrong?
>
> I always use tr:
>
> echo "XX" | tr '[A-Z]' '[a-z]'

Note that if you need to enter the murky waters of i18n then you
also need to distinguish between

    tr A-Z a-z

which will only lowercase the 26 "unadorned" uppercase letters and

    tr '[:upper:]' '[:lower:]'

which will also lowercase accented characters for reasonably
straightforward locale settings. If you want to handle more complex
Unicode lowercasing then you want to be using Perl's "tr" operator
(and/or uc(), lc(), regexps etc.). If you want *really* weird
Unicode stuff in all its full glory then even Perl may not get you
there (and you'll also have my full sympathy).

(Actually, the y/// syntax in Perl is a synonym for tr/// for those
who like the sed syntax plus you still get the nicer range behaviour
and hence
    echo "XX" | perl -pe 'y/A-Z/a-z/'
works as you'd expect it would.)

--Malcolm

--
Malcolm Beattie <[EMAIL PROTECTED]>
Linux Technical Consultant
IBM EMEA Enterprise Server Group...
...from home, speaking only for myself

Reply via email to