9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: W B Hacker <wbh@conducive.org>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] sed question (OT)
Date: Sat, 31 Oct 2009 01:30:15 +0800	[thread overview]
Message-ID: <4AEB22A7.7010109@conducive.org> (raw)
In-Reply-To: <2AC4018ADBC89F5A056B73E2@[192.168.1.2]>

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
> <steve@quintile.net> 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
>>
>
>
>
>
>
>




  reply	other threads:[~2009-10-30 17:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-29 15:41 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 [this message]
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
     [not found] <<80c99e790910290906t36766978kcd38c9583392e038@mail.gmail.com>
2009-10-29 16:08 ` erik quanstrom
2009-10-29 16:29   ` Iruata Souza
     [not found] <<d1c554290910290929p3980a256hf075042ca3a3917b@mail.gmail.com>
2009-10-29 16:31 ` erik quanstrom
     [not found] <<A3AADD7F-E09D-49F9-8A5B-3D6B720046A4@mac.com>
2009-10-30 16:16 ` erik quanstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AEB22A7.7010109@conducive.org \
    --to=wbh@conducive.org \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).