given the text file:
(the structure is: "group_name:pw:group_id:user1<,user2>...")
adm:x:4:syslog,adm1
admins:x:1006:adm2,adm12,manuel
ssl-cert:x:122:postgres
ala2:x:1009:aceto,salvemini
conda:x:1011:giovannelli,galise,aceto,caputo,haymele,salvemini,scala,adm2,adm12
adm1Group:x:1022:adm2,adm1,adm3
docker:x:998:manuel
how can i count the number of users for every line? or for a single line?
for example, if i want to know how many users contains the "adm1Group", the output should be 3, because adm1Group has three users (adm2, adm1 and adm3). another example, the first line (group name "adm"), contains two users, syslog and adm1.
the main problem is that there are two field separators here, so how can i separate the $4 column inside the same awk command? i have this solution by me but here i use two different awk commands linked with a pipe, like this (and i don't know if this is correct or "legal" for the kernel):
awk -F: '/adm1Group/ {print $4}' file.txt | awk -F, 'BEGIN {printf "N. of users in adm1Group = "} {print NF}'
can i achieve a solution like this in a single awk command? if not, can i use this? or this solution is "bad practice"?