|
Home > Archive > Unix Programming > April 2006 > simple diff script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
simple diff script
|
|
| mac8500 2006-04-11, 9:59 am |
| I'm looking for a simple shell script that would compare uid et gid
files on a bunch of servers (solaris, aix) from a white list. Looking
for a local solution as no nis, ldap, nis+ running.
I tought of using a diff -f and toy with the output (as it gives the ed
help lines). But there as to be a simpler way.
I also tought of using a single cmp line and mail myself the results
(server x, y, z are not identical) but i'm pretty much interested in
the output.
White list
root:0
test:89
user1:88
user2:89
user3:90
server x /etc/passwd
root:0
test:88
user1:88
user2:90
user3:91
Would report in a temp file user2, user3 on server x is different.
I know some sysadmins used that before 
| |
| Chris F.A. Johnson 2006-04-27, 7:55 am |
| On 2006-04-10, mac8500 wrote:
> I'm looking for a simple shell script that would compare uid et gid
> files on a bunch of servers (solaris, aix) from a white list. Looking
> for a local solution as no nis, ldap, nis+ running.
>
> I tought of using a diff -f and toy with the output (as it gives the ed
> help lines). But there as to be a simpler way.
>
> I also tought of using a single cmp line and mail myself the results
> (server x, y, z are not identical) but i'm pretty much interested in
> the output.
>
> White list
>
> root:0
> test:89
> user1:88
> user2:89
> user3:90
>
> server x /etc/passwd
>
> root:0
> test:88
> user1:88
> user2:90
> user3:91
>
> Would report in a temp file user2, user3 on server x is different.
>
> I know some sysadmins used that before 
If whitelist just contains fields 1 and 3 from /etc/passwd:
awk -F: 'FILENAME == "whitelist" { u[$1,$2]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd
If it contains the entire passwd file:
awk -F: 'FILENAME == "whitelist" { u[$1,$3]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd
--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
|
|
|
|
|