trying to extract groups that have only a member from each *.group file which contains list of groups and their members in a PASSGRP directory(the directory contains multiple *.passwd and *group files) add them to the group.ignore file and redirect the remaining groups with multiple users into a new $file foreach *.group file keeping the name of the original file.attached below is what i have.need help perfecting it.thanks

This is how I understand your problem. Please correct me where I am wrong.

The PASSGRP directory contains multiple *.passwd and *group files

Each of the .group files contains a list of groups and their members.

For each .group file in PASSGRP directory you must:

Remove groups, that have only a member (or are already in .ignore file)

Append those groups to the group.ignore file.

The code you provide has only one output file. It contains a list of groups. I cannot tell if these are the groups that you wish to append to the .ignore or if it is a list of all other groups. (I do not see anything in your code or text about how to tell how many users are in a group)

You probably need help with editing the .group files. This is a bit tricky. Lets get the requirements right before I try to explain it.

You can append to the .ignore file by opening it in append mode. Good Luck, Bill

You have not defined 'group' or 'member'. From your example, I can infer that each line of your .group file consists of a group name optionally followed by a comma-separated list of members. You want to write each line to either the 'server' file or the 'ignore' file depending on the number of members. (The line 'nobody' seems to be an exception. Is this a mistake in your example or have I missed something?)

Open the server file in output mode. Open the ignore file in append mode.

For each .group file Open the .group file in input mode. Read it one line at a time. If the line contains a comma: Write the line to the 'server' file. Else Write it to the 'ignore' file.

At end of file, close the .group file

After all group files have been read Close both output files.

This does not remove any lines from the .group file. I am still not clear enough on requirements to address that issue. Good Luck, Bill