[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The usage of \L of s in sed?
From: |
Bob Proulx |
Subject: |
Re: The usage of \L of s in sed? |
Date: |
Sat, 10 Jul 2010 18:57:40 -0600 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Peng Yu wrote:
> I still don't understand how to use \L in sed after reading the
> manual. Could you please show me some example on how to use it?
>
> echo "ABC" | sed -r -e 's/A/\L/g'
Start off by doing the replacement that you want to lower (or upper)
case. In this example I will use '&' to replace with the full input
match.
$ echo "ABC" | sed -r -e 's/B/&/g'
ABC
Then bracket your replacement with the translation you want.
$ echo "ABC" | sed -r -e 's/B/\L&\E/g'
AbC
You can do some of one and some of another. This uses numbered
backreferences and brackets them with upper and lower case
translations.
$ echo "Abc" | sed -r -e 's/^(.)/\1/g'
Abc
$ echo "Abc" | sed -r -e 's/^(.)(.)(.)/\L\1\U\2\E\3/g'
aBc
Hope that helps.
Bob