The script has a small "bug" one might say: it capitalizes the first two words on a line that are _not_ already capitalized. If one of the first two words is capitalized then the third will get capitalized.

--On Thursday, October 29, 2009 15:41 +0000 Steve Simon <st...@quintile.net> wrote:

Sorry, not really the place for such questions but...

I always struggle with sed, awk is easy but sed makes my head hurt.

I am trying to capitalise the first tow words on each line (I could use
awk as well but I have to use sed so it seems churlish to start another
process).

capitalising the first word on the line is easy enough:

                        h
                        s/^(.).*/\1/
                        y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
                        x
                        s/^.(.*)/\1/
                        x
                        G
                        s/\n//

Though there maye be a much easier/more elegant way to do this,
but for the 2nd word it gets much harder.

What I really want is sam's ability to select a letter and operate on it
rather than everything being line based as sed seems to be.

any neat solutions? (extra points awarded for use of the branch operator
:-)

-Steve






Reply via email to