From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4AEB22A7.7010109@conducive.org> Date: Sat, 31 Oct 2009 01:30:15 +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: <2AC4018ADBC89F5A056B73E2@[192.168.1.2]> In-Reply-To: <2AC4018ADBC89F5A056B73E2@[192.168.1.2]> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [9fans] sed question (OT) Topicbox-Message-UUID: 94a99b8e-ead5-11e9-9d60-3106f5b1d025 Eris Discordia wrote: > 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. Call me a Dinosaur, but - so long as it is ASCII or EBCDIC it is relatively trivial to implement that in hardware AND NOT have the issue of altering any but the first two words AND NOT have issues where there is only one word or a numeral or punctuation or hidden/control character rather than alpha. Hint: Among other simple stuff, needs XOR capability. 'Dinosaur' 'coz the last time I did one of the key portions of it was converting a Data Printer CT-1064 chaintrain from HP-3000 MKIII use to work with an S-100 Z-80. That capitalized *every* alpha character, but took just two 74-series IC's to replace a pair of lookup-table PROMS. One would need to add logic to detect space or newline, set/unset a few latches - not a lot more. Could have built it in less time than this thread has been running... ;-) Bill > > --On Thursday, October 29, 2009 15:41 +0000 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 >> > > > > > >