9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Sam / text search query
@ 2002-06-20 18:58 David Gordon Hogan
  2002-06-21 15:00 ` Douglas A. Gwyn
  0 siblings, 1 reply; 11+ messages in thread
From: David Gordon Hogan @ 2002-06-20 18:58 UTC (permalink / raw)
  To: 9fans

>> > not forgetting that the "s" command supports \(...\) etc.
>> ...while remembering that, as with all regexps in plan 9,
>> the old ed-like \( and \) become egrep-like ( and ),
>
> Yeah, actually that's a pet peeve.

I'm a little confused.  Are you peeved at egrep's behaviour,
sam's regexp behaviour, or both?

I much prefer sam's behaviour (which is actually Plan 9
regexp's behaviour in general).  You can escape anything
with "\".  In egrep, both '(' and '\(' are (different)
metacharacters.



^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [9fans] Sam / text search query
@ 2002-06-20 16:21 rog
  0 siblings, 0 replies; 11+ messages in thread
From: rog @ 2002-06-20 16:21 UTC (permalink / raw)
  To: 9fans

from /sys/doc/sam.ms:

: Egrep expressions are arguably too complicated for an interactive
: editor -- certainly it would make sense if all the special characters
: were two-character sequences, so that most of the punctuation
: characters wouldn't have peculiar meanings -- but for an interesting
: command language, full regular expressions are necessary, and egrep
: defines the full regular expression syntax for UNIX programs.  Also,
: it seemed superfluous to define a new syntax, since various UNIX
: programs (ed, egrep and vi) define too many already.

i have to say i wouldn't mind a new regexp syntax with fewer metachars.



^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [9fans] Sam / text search query
@ 2002-06-19 16:08 rog
  2002-06-20 15:47 ` Douglas A. Gwyn
  0 siblings, 1 reply; 11+ messages in thread
From: rog @ 2002-06-19 16:08 UTC (permalink / raw)
  To: 9fans

> not forgetting that the "s" command supports \(...\) etc.

...while remembering that, as with all regexps in plan 9,
the old ed-like \( and \) become egrep-like ( and ),
so the old:

	s/\([a-z]*\) \([a-z]*\)/\2 \1/

becomes:

	s/([a-z]*) ([a-z]*)/\2 \1/



^ permalink raw reply	[flat|nested] 11+ messages in thread
* [9fans] Sam / text search query
@ 2002-06-18 21:06 Andrew Simmons
  2002-06-19 15:37 ` Douglas A. Gwyn
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Simmons @ 2002-06-18 21:06 UTC (permalink / raw)
  To: 9fans

> this is the easiest way
>
>	,x g/sprintf/ .,/.*msgprint.*\n/ p
>
>it seems easy to me, almost a transcription of what you're asking to
>do.
>
>if you have multiple sprintfs before msgprint, though, you might
>prefer this:
>
>	,x g/msgprint/ ?.*sprintf.*\n?,.p
>
>subtler but maybe more correct; your specification was ambiguous.

Brilliant, thanks. Your second method is exactly what I wanted, your
first the best I was expecting. Would that it seemed as easy to me,
but my brain locks up and turns to custard when faced with regular
expressions beyond a minimal level of complexity.




^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: [9fans] Sam / text search query
@ 2002-06-18 17:31 Gerry Tomlinson
  0 siblings, 0 replies; 11+ messages in thread
From: Gerry Tomlinson @ 2002-06-18 17:31 UTC (permalink / raw)
  To: 9fans


>> 
> Drifting ever more OT, has anyone had problems running Sam under 
> Windows 2000? It seems to start happily enough, but then gets angry 
> and refuses to respond to anything I type in the command window, 
> before finally locking up under circumstances I have not so far 
> managed to identify.
> 


i get similar behaviour if i have cleverkeys running, a utility which
intercepts keystrokes in all applications,

	gerry

---
gerry.tomlinson@newcastle.ac.uk
computing officer
department of computing Science, university of newcastle, tel: +44 191
222 8139
newcastle upon Tyne, ne1 7ru, united kingdom.             fax: +44 191
222 8232
 





^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: [9fans] Sam / text search query
@ 2002-06-18  5:07 rob pike, esq.
  0 siblings, 0 replies; 11+ messages in thread
From: rob pike, esq. @ 2002-06-18  5:07 UTC (permalink / raw)
  To: 9fans

this is the easiest way

	,x g/sprintf/ .,/.*msgprint.*\n/ p

it seems easy to me, almost a transcription of what you're asking to do.

if you have multiple sprintfs before msgprint, though, you might
prefer this:

	,x g/msgprint/ ?.*sprintf.*\n?,.p

subtler but maybe more correct; your specification was ambiguous.

-rob



^ permalink raw reply	[flat|nested] 11+ messages in thread
* [9fans] Sam / text search query
@ 2002-06-18  5:03 Andrew Simmons
  2002-06-18 15:03 ` Douglas A. Gwyn
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Simmons @ 2002-06-18  5:03 UTC (permalink / raw)
  To: 9fans

Sorry if this is slightly OT here, but I thought it was the likeliest
place to get an answer. I have a problem I was hoping to use Sam for,
partly so that I have an incentive to get better at using the command
language, but I'm too thick to work out how to do what I want.

I have a large number of files, and for each one I need to print out
all sequences of adjacent lines such that the first line in the
sequence contains "sprintf" and the last line contains "msgprint".
Ideally there should be no other occurences of "sprintf" in the
sequence of lines, but I can live with it if there are. My naïve
attempt to do this resulted in the selection of the sequence of lines
from the first "sprintf" to the final "msgprint". Can some kind soul
point out how to do what I want, or failing that suggest an
alternative tool - I could write a program, but feel it shouldn't be
necessary.

Drifting ever more OT, has anyone had problems running Sam under
Windows 2000? It seems to start happily enough, but then gets angry
and refuses to respond to anything I type in the command window,
before finally locking up under circumstances I have not so far
managed to identify.


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

end of thread, other threads:[~2002-06-21 15:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-20 18:58 [9fans] Sam / text search query David Gordon Hogan
2002-06-21 15:00 ` Douglas A. Gwyn
  -- strict thread matches above, loose matches on Subject: below --
2002-06-20 16:21 rog
2002-06-19 16:08 rog
2002-06-20 15:47 ` Douglas A. Gwyn
2002-06-18 21:06 Andrew Simmons
2002-06-19 15:37 ` Douglas A. Gwyn
2002-06-18 17:31 Gerry Tomlinson
2002-06-18  5:07 rob pike, esq.
2002-06-18  5:03 Andrew Simmons
2002-06-18 15:03 ` Douglas A. Gwyn

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