9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sed question (OT)
@ 2009-10-29 15:41 Steve Simon
  2009-10-29 16:06 ` Lorenzo Bolla
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Steve Simon @ 2009-10-29 15:41 UTC (permalink / raw)
  To: 9fans

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



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-11-11 12:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-29 15:41 [9fans] sed question (OT) Steve Simon
2009-10-29 16:06 ` Lorenzo Bolla
2009-10-29 16:33   ` Iruata Souza
2009-10-29 16:42     ` Lorenzo Bolla
2009-10-29 16:09 ` W B Hacker
2009-10-29 18:52 ` Jason Catena
2009-10-30 13:35 ` Eris Discordia
2009-10-30 13:39 ` Eris Discordia
2009-10-30 17:30   ` W B Hacker
2009-10-30 17:39     ` [9fans] sed question (OT) (OT) (OT) Tim Newsham
2009-10-30 18:14       ` [9fans] sed question (OT) (OT) (OT) (OT) (OT)(OT)(OT)(OT)(OT)(OT)(OT)(OT)(OT)(OT) W B Hacker
2009-10-30 15:29 ` [9fans] sed question (OT) dave.l
2009-10-30 20:53 ` Noah Evans
2009-11-11 12:32 ` frankg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).