9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Jason Catena <jason.catena@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] sed question (OT)
Date: Thu, 29 Oct 2009 13:52:55 -0500	[thread overview]
Message-ID: <d50d7d460910291152t31474101yb762bfbda9de620b@mail.gmail.com> (raw)
In-Reply-To: <f631016df731e553421e6079dd1da0d4@quintile.net>

> 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



  parent reply	other threads:[~2009-10-29 18:52 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 [this message]
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
     [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=d50d7d460910291152t31474101yb762bfbda9de620b@mail.gmail.com \
    --to=jason.catena@gmail.com \
    --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).