From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4AE9BE25.1090001@conducive.org> Date: Fri, 30 Oct 2009 00:09:09 +0800 From: W B Hacker User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.23) Gecko/20090823 SeaMonkey/1.1.18 MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [9fans] sed question (OT) Topicbox-Message-UUID: 935921aa-ead5-11e9-9d60-3106f5b1d025 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 > > I'd be sore tempted to move the needful files into an environment where I could use multiple passes of 'rpl' (or 'back in the day' BRIEF). BFBI .. far less capable tools, perhaps - BUT by the time you've figured out how to even *tell* awk or sed what to do, I'm working on some other task... 'If at first you don't succeed - cheat' YMMV, Bill