From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 29 Oct 2009 16:06:40 +0000 Message-ID: <80c99e790910290906t36766978kcd38c9583392e038@mail.gmail.com> From: Lorenzo Bolla To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=000e0cd242b0c9f7f204771518cc Subject: Re: [9fans] sed question (OT) Topicbox-Message-UUID: 93602108-ead5-11e9-9d60-3106f5b1d025 --000e0cd242b0c9f7f204771518cc Content-Type: text/plain; charset=ISO-8859-1 To capitalize the first letter of each line wouldn't this be enough? s/^./\u&/ L. On Thu, Oct 29, 2009 at 3:41 PM, Steve Simon 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 > > --000e0cd242b0c9f7f204771518cc Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable To capitalize the first letter of each line wouldn't this be enough?
s/^./\u&/

L.


=
On Thu, Oct 29, 2009 at 3:41 PM, Steve Simon <steve@quintile.net= > wrote:
Sorry, not really the place for such questi= ons 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:

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0h
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s/^(.).*/\1/
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0y/abcdefghijklmnopqrstuvwxy= z/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0x
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s/^.(.*)/\1/
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0x
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0G
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s/\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 i= t
rather than everything being line based as sed seems to be.

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

-Steve


--000e0cd242b0c9f7f204771518cc--