[PLUG] Sed and POSIX character class question

Dave Houston dave.houston at gmail.com
Sat Sep 9 07:16:40 UTC 2006


On Thu, 2006-09-07 at 18:34 -0700, Nathaniel Nuss wrote:
> On Thu, Sep 07, 2006 at 07:58:19AM -0700, David Pool wrote:
> > I've been playing around with sed recently and am surprised by why and
> > how this line doesn't accomplish the task I intended, which would be
> > capitalizing the first lower case letter in each line:
> > 
> > sed 's/[[:lower:]]/[[:upper:]]/' testing.txt
> 
> How about:
> 
> sed 's/[[:lower:]]/\u&/'

I did:
perl -i.bak -pe's/^(.*?)([a-z])(.*)/$1\u$2$3/' inputfile

And was pretty verbose with the regexp, just to be on the safe side.
-- 
Dave Houston <dave.houston at gmail.com>




More information about the PLUG mailing list