Gurus
I am trying to capture all the data in /etc/group file in a CSV ,thru a fingerprinting engine.
For hosts having ,unique group names and Ids ,following code works fine.
Trouble starts when on a host,there are multiple groups defined with same name and id.
e.g One of my hosts has 8 groups defined with [same]name "operators" and [same] id "542".
Query1:
How can i capture all these 8 groups with following script lines?
Query2:
myHost operators 542 jackS johnM 2009-12-01
I am getting two names in the third column (userlist).'jackS' is where first group entry ends and 'johnM' is where second or next entry begins.
How can this be avoided?
Query3:
Is it possible to define multiple groups with same name and id?
Family Name:Host etcGroup
DUP:
cat /etc/group | awk -F':' '{print $1$3}'
GroupName:
A=`cat /etc/group |awk -F':' '{if ($1$3 == "@@Host etcGroup.DUP@@" ) print $1}'|sort|uniq`
echo $A
GID:
A=`cat /etc/group |awk -F':' '{if ($1$3 == "@@Host etcGroup.DUP@@" ) print $3}'|sort|uniq`
echo $A
Userlist:
A=`cat /etc/group|awk -F':' '{if ($1$3 == "@@Host etcGroup.DUP@@" ) print $4}'|sort|uniq`
B=`echo $A|wc -w`
if [ $B = 0 ]
then
echo NULL
else
count=`echo $A| nawk -F, {'print NF'}`
i=1
while [ $i -le $count ]
do
str[$i]=`echo $A| cut -d, -f${i}`
echo "${str[$i]}"
i=`expr $i + 1`
done
fi
Regards
Abhi