perl script to rationalize /etc/groups
Hi all,
I am trying to write a simple perl script to optimize my /etc/groups, to make sure that it doesn't contain any members that don't have corresponding /etc/passwd entries. here's what I have so far, but it all seems a little cumbersome: Code:
#!/usr/local/bin/perl (PS: it needs to be in perl, as it's also for my programming class :) ) |
yes, you can try to use a hash:
store all the usernames in a hash, %users (values are not important, we need to keys only). and you can write your search as: grep (! exists $users{$_}, split(/,/, $members)); Not tested, there can be other possibilities, for example using map. |
1. always use -w & strict
Code:
#!/usr/bin/perl -w Code:
open(KFILE, "<", "kfile.txt" ) or die "Can't open kfile: $!\n"; http://perldoc.perl.org/ http://www.perlmonks.org/?node=Tutorials http://www.tizag.com/perlT/index.php |
All times are GMT -5. The time now is 03:42 PM. |