9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sam command language question
@ 2012-08-20 11:12 Steve Simon
  2012-08-20 11:55 ` Rudolf Sykora
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steve Simon @ 2012-08-20 11:12 UTC (permalink / raw)
  To: 9fans

Tis the season for exotic sam command language questions,
though mine is not that exotic.

I want to edit some xml (yes I know) and capitalise all the labels
in it. I only want to do this once so I don't care that it will
envoke tr thousands of times and take a minuite or so.

This is what I tried:

	,x/label="[^"]+"/ {
		x/ [a-z]/ | tr a-z A-Z
	}

sadly the inner 'x' searches onward in the file and not in
the selection (dot) generated by the outer 'x'.

I tried a few more random commands but nothing very sensible,
anyone any ideas?

Seems somthing that should be easy...

-Steve



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sam command language question
  2012-08-20 11:12 [9fans] sam command language question Steve Simon
@ 2012-08-20 11:55 ` Rudolf Sykora
  2012-08-20 12:05 ` Rudolf Sykora
  2012-08-20 12:15 ` Rudolf Sykora
  2 siblings, 0 replies; 6+ messages in thread
From: Rudolf Sykora @ 2012-08-20 11:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 20 August 2012 13:12, Steve Simon <steve@quintile.net> wrote:
> Tis the season for exotic sam command language questions,
> though mine is not that exotic.
>
> I want to edit some xml (yes I know) and capitalise all the labels
> in it. I only want to do this once so I don't care that it will
> envoke tr thousands of times and take a minuite or so.
>
> This is what I tried:
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> sadly the inner 'x' searches onward in the file and not in
> the selection (dot) generated by the outer 'x'.
>
> I tried a few more random commands but nothing very sensible,
> anyone any ideas?
>
> Seems somthing that should be easy...
>
> -Steve
>

1) what's wrong with
,x/label="[^"]+"/ | tr a-z A-Z
?
(besides that it also capitalizes label -> LABEL; but this would do
your code too)

2) I will think about your own code later.

Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sam command language question
  2012-08-20 11:12 [9fans] sam command language question Steve Simon
  2012-08-20 11:55 ` Rudolf Sykora
@ 2012-08-20 12:05 ` Rudolf Sykora
  2012-08-20 12:15 ` Rudolf Sykora
  2 siblings, 0 replies; 6+ messages in thread
From: Rudolf Sykora @ 2012-08-20 12:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 20 August 2012 13:12, Steve Simon <steve@quintile.net> wrote:
> This is what I tried:
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> sadly the inner 'x' searches onward in the file and not in
> the selection (dot) generated by the outer 'x'.

I do not see the reported behaviour. For me it searches through the
dot prepared by the first 'x' command... Thanks to the 'space'
character in the second 'x' it however capitalizes only the first
letter of any word in paranthesis which has a space in front of
itself.

Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sam command language question
  2012-08-20 11:12 [9fans] sam command language question Steve Simon
  2012-08-20 11:55 ` Rudolf Sykora
  2012-08-20 12:05 ` Rudolf Sykora
@ 2012-08-20 12:15 ` Rudolf Sykora
  2012-08-20 12:25   ` Steve Simon
  2 siblings, 1 reply; 6+ messages in thread
From: Rudolf Sykora @ 2012-08-20 12:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 20 August 2012 13:12, Steve Simon <steve@quintile.net> wrote:
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }

Perhaps, also, I haven't correctly understood what you are after. If
what I wrote doesn't solve the problem, an example of what is needed
would help.

Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sam command language question
  2012-08-20 12:15 ` Rudolf Sykora
@ 2012-08-20 12:25   ` Steve Simon
  2012-08-20 13:21     ` Rudolf Sykora
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Simon @ 2012-08-20 12:25 UTC (permalink / raw)
  To: 9fans

I am confused, and appologise to all for the noise.

	,x/label="[^"]+"/ {
		x/ [a-z]/ | tr a-z A-Z
	}

does exactly what I wanted, I don't understand why in my toy tests it
didn't appear to work, probably a typo.

for the record I was tring to do this:

	label="Hello"
->
	label="Hello"      (i.e. unchanged)

	label="Hello world and other planets"
->
	label="Hello World And Other Planets"

-Steve



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [9fans] sam command language question
  2012-08-20 12:25   ` Steve Simon
@ 2012-08-20 13:21     ` Rudolf Sykora
  0 siblings, 0 replies; 6+ messages in thread
From: Rudolf Sykora @ 2012-08-20 13:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 20 August 2012 14:25, Steve Simon <steve@quintile.net> wrote:
> I am confused, and appologise to all for the noise.
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> does exactly what I wanted, I don't understand why in my toy tests it
> didn't appear to work, probably a typo.
>
> for the record I was tring to do this:
>
>         label="Hello"
> ->
>         label="Hello"      (i.e. unchanged)
>
>         label="Hello world and other planets"
> ->
>         label="Hello World And Other Planets"
>
> -Steve
>

You could also use something like the following. It would, compared to
your code, also capitalize the very first word in the quotation marks
(your Hello, if it were hello).

,x/label="[^"]+"/ .-#0+#7,.+#0-#1 y/ / .-#0,.-#0+#1 | tr a-z A-Z

It finds the label="stuff", then limits to stuff, then breaks into
words, then capitalizes the first letter of each word.

Ruda



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-20 13:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-20 11:12 [9fans] sam command language question Steve Simon
2012-08-20 11:55 ` Rudolf Sykora
2012-08-20 12:05 ` Rudolf Sykora
2012-08-20 12:15 ` Rudolf Sykora
2012-08-20 12:25   ` Steve Simon
2012-08-20 13:21     ` Rudolf Sykora

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).