My text file contains a line that consists of a group,e.g., 50005, following the group number, there are one more user name, e.g., usera, userb. Each group and user name is separated by a newline.
50000
Craig
Mark
50001
Craig
Steve
50002
Durlene
Floyd
Jeremy
Kent
Leroy
Jessie
Rocky
Sean
Craig
Jeffrey
Rick
#!/usr/bin/perl use warnings; use strict; # comments for myscript_342.pl my $groups; my @line; open my $file, "<", "groupsmembers.txt"; open my $output, ">", "/mnt/backup/output.txt"; while (<$file>) { push @line, $_; } chomp @line; for (@line) { s/^\d+/\n/; s/(\w+)/$1,/; print $output "$_"; }
The above script sorta does what I want, which is to separate the groups and list the user names like: usera, userb, userc each entire group members separated by a newline.
50000 Craig, Mark
In reply to ADSI groups users by techjohnny
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |