Disclaimer: I did not set out to write the next big thing...
I'm simply collecting all of the group information for all of the users across disparate hosts.
I wrote a simple script to collect all of the group information for each user on a system and pushed it out to each host:
#!/bin/sh
for user in `awk -F: '{print $1}' /etc/passwd`; do echo "$user:"; groups $user; echo "#################"; done
I collected them on a central host
for host in `cat hosts`; do ssh $host /tmp/myScript.sh >> ../collected/$host; done
To clean it up and move each new group onto it's own line, I quickly ran it through tr
cd ../collected
for file in `ls`; do tr ' ' '\n' < $file >> ../uidgames/$file; done
But now, I'm left with a handful of files that look like this:
daemon:
other
bin
adm
daemon
#################
bin:
bin
sys
#################
sys:
sys
#################
adm:
adm
sys
tty
lp
#################
lp:
lp
#################
Ideally, I'd like the file to look like this:
daemon:other
daemon:bin
daemon:adm
daemon:daemon
bin:bin
bin:sys
sys:sys
adm:adm
adm:sys
adm:tty
adm:lp
lp:lp
And then I'll collect them all together with a simple:
for file in `ls`; do awk '{print FILENAME":"$0}' $file >> ../result; done
This is a file that I can drop into Excel to get moving on my UID/GID cleanup plan.
I've been playing with this for 30 minutes, but need to go home before I start seeing hash marks everywhere.
If you have a great idea to do this all from go to whoa, great, but all I'm really looking for is that one piece. I'll munge it all together later, just looking for "quick and dirty" right now...
Thanks!
- Avron