From: Greg Beeker on
I am looking for a regular expression that can identify text from the
stanza listed below. Specifically, where the beginning of the line is
"root:" and the text "rlogin = false" appears prior to the next time a
":"
occurs.

I am using a product called BindView control for Unix, and I can not
run a general command, but I can create a regular expression to
extract data from the file. Is there a a regular expression for this?

root:
admin = true
SYSTEM = "compat"
registry = files
loginretries = 0
account_locked = false
maxage = 0
minalpha = 0
minother = 0
rlogin = false
sugroups = rgrp
minlen = 0

I have tried a few things, without much success.
From: Maxwell Lol on
Greg Beeker <gbeeker(a)gmail.com> writes:

> I am looking for a regular expression that can identify text from the
> stanza listed below. Specifically, where the beginning of the line is
> "root:" and the text "rlogin = false" appears prior to the next time a
> ":"
> occurs.

Regular expressions usually do not allow newlines. Test if BindVIew allows this.
>
> root:
> admin = true
> SYSTEM = "compat"
> registry = files


Search for "\nroot:"
if that doesn't work, then I thing you are unable to fix it.

Can you use a shell command from BindView?
Or use an external routine that pre-parses the file?
From: Toby Darling on
On Jun 18, 7:47 pm, Greg Beeker <gbee...(a)gmail.com> wrote:
> I am looking for a regular expression that can identify text from the
> stanza listed below. Specifically, where the beginning of the line is
> "root:" and the text "rlogin = false" appears prior to the next time a
> ":"
> occurs.
>
> I am using a product called BindView control for Unix, and I can not
> run a general command, but I can create a regular expression to
> extract data from the file. Is there a a regular expression for this?
>
> root:
> admin = true
> SYSTEM = "compat"
> registry = files
> loginretries = 0
> account_locked = false
> maxage = 0
> minalpha = 0
> minother = 0
> rlogin = false
> sugroups = rgrp
> minlen = 0
>
> I have tried a few things, without much success.

I'm sure the awk golfers will improve on this:

awk '/root:/ { z=1; next }; /.*:/ {z=0; next}; /rlogin =/ {if(z == 1)
{print}};' stanza_file
From: Hermann Peifer on
On Jun 19, 12:53 pm, Toby Darling <anothercof...(a)googlemail.com>
wrote:
> On Jun 18, 7:47 pm, Greg Beeker <gbee...(a)gmail.com> wrote:
>
>
>
> > I am looking for a regular expression that can identify text from the
> > stanza listed below. Specifically, where the beginning of the line is
> > "root:" and the text "rlogin = false" appears prior to the next time a
> > ":"
> > occurs.
>
> > I am using a product called BindView control for Unix, and I can not
> > run a general command, but I can create a regular expression to
> > extract data from the file. Is there a a regular expression for this?
>
> > root:
> > admin = true
> > SYSTEM = "compat"
> > registry = files
> > loginretries = 0
> > account_locked = false
> > maxage = 0
> > minalpha = 0
> > minother = 0
> > rlogin = false
> > sugroups = rgrp
> > minlen = 0
>
> > I have tried a few things, without much success.
>
> I'm sure the awk golfers will improve on this:
>
> awk '/root:/ { z=1; next }; /.*:/ {z=0; next}; /rlogin =/ {if(z == 1)
> {print}};' stanza_file

If blocks happen to be separated by empty lines, you could do:

gawk -v RS= '/^root:[^:]*rlogin = false/' yourfile

Hermann