[PLUG] Sed and POSIX character class question
David Pool
dpool at hevanet.com
Thu Sep 7 14:58:19 UTC 2006
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
The file "testing.txt" contains this line:
THIS IS a lower case letter.
The result of the command is:
THIS IS [[:upper:]] lower case letter.
So it seems to use the POSIX character class to find the first lower
case letter, but then instead of replacing it with a matching upper case
letter, it inserts the string "[[:upper:]]"
Two questions:
Any idea why sed works like this?
Other solutions?
Thanks,
David
More information about the PLUG
mailing list