Regex to find a word, then extract a line containing the first occurence of a different word immedia
Posted
by Hinchy
on Stack Overflow
See other posts from Stack Overflow
or by Hinchy
Published on 2010-03-12T11:53:11Z
Indexed on
2010/03/12
11:57 UTC
Read the original article
Hit count: 199
regex
World's most convuluted title I know, an example should explain it better. I have a large txt file in the below format, though details and amount of lines will change everytime:
Username: john_joe Owner: John Joe
Account:
CLI:
Default:
LGICMD:
Flags:
Primary days:
Secondary days:
No access restrictions
Expiration:
Pwdlifetime:
Last Login:
Maxjobs:
Maxacctjobs:
Maxdetach:
Prclm:
Prio:
Queprio:
CPU:
Authorized Privileges:
BYPASS
Default Privileges:
SYSPRV
This sequence is repeated a couple of thousand times for different users. I need to find every user (ideally the entire first line of the above) that has SYSPRV under "Default Permissions". I know I could write an application to do this, I was just hoping their might be a nice regex I could use.
Cheers
© Stack Overflow or respective owner