Re: [9fans] ed regular expressions in sam

2021-07-20 Thread revcomninos
Thank you. Those distinctions are very helpful. I agree that thinking in terms of lines is easier to reason about. I am going to have to change some of my thinking and break old habits.  -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread Silas McCroskey
> I have yet gotten to this usage of "g" after "s". The key difference here is not in the behavior of suffixed 'g', but in how selections are made and operated on in the first place. Ed's "selection" (aka dot, as you can reference it with '.') is always a full, single line. It can *iterate* over

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread revcomninos
Thank you for the clarification. This first usage conforms to ed. I am currently working slowly through "A Tutorial for the Sam Command Language"  http://doc.cat-v.org/bell_labs/sam_lang_tutorial/ but I have yet gotten to this usage of "g" after "s". -- 9fa

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread Silas
In sam, g has two uses - either as a guard or after an s command where all substitutions are made Quoting sam(1) (available at ) after an s command: > If the command is followed by a g, as in >    s/x/y/g, all matches in the range are substituted. as

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread revcomninos
I.e. in sam. In ed, g is frequently used at the end of the line.  -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te7fcdc06a68bb777-M976ef16f9b129d3abeaa2511 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread revcomninos
Thank you all for your responses. They were extremely helpful. The first example, which uses "g" threw me a little because I am not used to "g" at the end of the line. I presume it here means something like, "without changing the value of dot?" -- 9fans: 9

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread Rob Pike
I would ,x s/.*/echo "&"/ as it seems most direct. The ,x idiom is the thing that turns sam into ed. -rob On Tue, Jul 20, 2021 at 9:18 PM wrote: > or: > > ,x/^/i/echo " > ,x/$/i/" > -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread umbraticus
or: ,x/^/i/echo " ,x/$/i/" -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te7fcdc06a68bb777-M3a70c9ddc3e626951d6349fb Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread revcomninos
Thank you. I will test this an revert back. -- 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te7fcdc06a68bb777-Mc5bcc7a82cda1c6c53ac3225 Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Re: [9fans] ed regular expressions in sam

2021-07-20 Thread Alex Musolino
> In ed it is trivial to edit either side of a line such as changing > the line, > > I use sam and ed > > to, > > echo "I use sam and ed." > > simply with, > > g/.*/s//echo "&."/ > > I am trying to figure out how to do the same in sam.  ,s/^.*$/echo "&."/g or, perhaps closer to your ed exam