I have a file with 40 lines like this:
0001.Group admin_group
0001.Users adam, sam, paul, david, jennifer, harry
0002.Group Dev_group
0002.Users mike, pauli, gary, sherry
0003.Group Sec_group
0003.Users david, diana, mike, paul, harry
0004.Group Main_group
0004.Users wilson, robert, samule
I need to extract the Group and Users using the prefix and create a new file with the same name as the group.
Should look like this:
Output filename:
admin_group
, contents:0001.Group admin_group 0001.Users adam, sam, paul, david, jennifer, harry
Output filename:
Dev_group
, contents:0002.Group Dev_group 0002.Users mike, pauli, gary, sherry
In the end, I need to have 20 new text files. I tried using sed and awk to create two separate files and failed. How can I get this in Bash or Python?