Extracting all group members
Hello,
I want to extract all members of a group, but I don't get the output that I want: Code:
GROUP=groupname username1 username3 .... Is it good practice in shell script to save such data in a file and then read the file when the data shall be used or are there better techniques? Thanks. |
Quote:
Code:
awk -F: '/^'$GROUP'/ { gsub(/,/,"\n",$4) ; print $4 }' /etc/group Quote:
|
That works, thank you :-) To be more precise: Is it a good choice to store the extracted data set in a file or is better to store the data in some kind of shell script data structure? E.g., in Java or C++ you often store file data in arrays or lists and then you just loop through this data structure. However, transferring Java way of thinking to shell scripting is often not possible that's why I am asking this question.
|
Quote:
Bash, awk and perl (to name just 3) can use array's if needed. Do check the specific documentation, I'm sure that array's are handled differently then in Java or C(++). These might help: Bash resources:
Sed/Awk resources:
|
All times are GMT -5. The time now is 02:47 AM. |