|
From: Greg Beeker on 18 Jun 2008 14:47 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 18 Jun 2008 22:07 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 19 Jun 2008 06:53 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 19 Jun 2008 08:46 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
|
Pages: 1 Prev: Find duplicate files AND ignore .svn folders Next: multiple substitutions with sed |