in reply to Re: Re: /etc/passwd
in thread Building data structure from several /etc/passwd files
#!/usr/bin/perl $nf="endo"; foreach $file (@ARGV) { open (PASSWD, "$file") || die "Couldn't open $file\n"; while (<PASSWD>) { ($login, $passwd, $uid, $gid, $gcos, $home, $shell) = split(/:/); $USERS{${file}.${login}} = $gcos; #this way the first key is "passwd.server1.root" } close (PASSWD); } open (NEWFILE, ">$nf"); foreach $login (sort keys %USERS) { print NEWFILE "$login, $USERS{$login}\n"; } close (NEWFILE); # just because I'm tidy
|
|---|