From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 29 Oct 2009 13:52:55 -0500 Message-ID: From: Jason Catena To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [9fans] sed question (OT) Topicbox-Message-UUID: 9387f34a-ead5-11e9-9d60-3106f5b1d025 > Sorry, not really the place for such questions but... Try stackoverflow.com. They delight in problems such as these. > I am trying to capitalise the first tow words on each line I store the original line with h, and then pull it back out repeatedly with G to mangle it. I got far enough to translate "first second ..." to "First s" with this: h s/^(.).*/\1/ y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ G s/^.([^ ]+ ).*/\1/ s/^.([^ ]+)$/\1/ G s/^.[^ ]+ (.).*/\1/ #y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ #3y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/ s/\n//g There's a couple problems. (1) It doesn't handle the case with only one word on a line, because it's hard to tell, later on, that I pulled out the single word once already. (2) I'd like to put in one of the commented-out y commands, but (2a) the first uppercases the entire pattern space, and (2b) the second refers to line 3 of the entire file, not line 3 of the pattern space. > -Steve Jason Catena