Greetings, could anyone please assist me with a following. I am trying to parse off and reconstruct the input file
that would have a multiple sections separated by "-------------".
I would like to extract two parts of each section. First is value of the records that starts with "Name:".
Second section is a more complex since I need to be able to extract a list of all role values under the "Roles:" section.
Please note, that the number of these roles can vary from section to section.
Thank you in advance.
Here is a fragment of the input file:
-------------
Name: 112233
ID: 95
E-mail address: (None)
E-mail form: Linked
E-mail notification type: Server
Home folder: (None)
Default printer: (None)
Max. priority: 500
Viewing preference: Default
Max. completed notices: 0
Success notification expr.: No limit
Failure notification expr.: No limit
Server notification type: All
Default file user privileges:
(None)
Default file role privileges:
(None)
Roles:
Role1
Role2
Role3
Groups:
(None)
Channels:
(None)
--------------
Name: 445566
ID: 95
E-mail address: (None)
E-mail form: Linked
E-mail notification type: Server
Home folder: (None)
Default printer: (None)
Max. priority: 500
Viewing preference: Default
Max. completed notices: 0
Success notification expr.: No limit
Failure notification expr.: No limit
Server notification type: All
Default file user privileges:
(None)
Default file role privileges:
(None)
Roles:
Role4
Role5
Role6
Role7
Role8
Groups:
(None)
Channels:
(None)
--------------
The output should look like this:
ADDUSER 112233
ADDUIG Role1 112233
ADDUIG Role2 112233
ADDUIG Role3 112233
ADDUSER 445566
ADDUIG Role4 445566
ADDUIG Role5 445566
ADDUIG Role6 445566
ADDUIG Role7 445566
ADDUIG Role8 445566
that would have a multiple sections separated by "-------------".
I would like to extract two parts of each section. First is value of the records that starts with "Name:".
Second section is a more complex since I need to be able to extract a list of all role values under the "Roles:" section.
Please note, that the number of these roles can vary from section to section.
Thank you in advance.
Here is a fragment of the input file:
-------------
Name: 112233
ID: 95
E-mail address: (None)
E-mail form: Linked
E-mail notification type: Server
Home folder: (None)
Default printer: (None)
Max. priority: 500
Viewing preference: Default
Max. completed notices: 0
Success notification expr.: No limit
Failure notification expr.: No limit
Server notification type: All
Default file user privileges:
(None)
Default file role privileges:
(None)
Roles:
Role1
Role2
Role3
Groups:
(None)
Channels:
(None)
--------------
Name: 445566
ID: 95
E-mail address: (None)
E-mail form: Linked
E-mail notification type: Server
Home folder: (None)
Default printer: (None)
Max. priority: 500
Viewing preference: Default
Max. completed notices: 0
Success notification expr.: No limit
Failure notification expr.: No limit
Server notification type: All
Default file user privileges:
(None)
Default file role privileges:
(None)
Roles:
Role4
Role5
Role6
Role7
Role8
Groups:
(None)
Channels:
(None)
--------------
The output should look like this:
ADDUSER 112233
ADDUIG Role1 112233
ADDUIG Role2 112233
ADDUIG Role3 112233
ADDUSER 445566
ADDUIG Role4 445566
ADDUIG Role5 445566
ADDUIG Role6 445566
ADDUIG Role7 445566
ADDUIG Role8 445566