Skip to content

Instantly share code, notes, and snippets.

@jciechowski
Created January 10, 2012 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jciechowski/1590462 to your computer and use it in GitHub Desktop.
Save jciechowski/1590462 to your computer and use it in GitHub Desktop.
W pliku /etc/group pierwszy element wiersza to nazwa grupy. W pliku /etc/passwd pierwszy element to login. Znajdź wszystkie loginy, które nie mają identycznie nazwanej grupy.
#!/bin/perl -w
use strict;
my @group = ();
my @passwd = ();
my %A;
open(GROUP,'</etc/group') or die "Nie mozna otworzyc group!:$!";
while(<GROUP>) {
chomp;
@group = split(':',$_);
$A{$group[0]}=$group[0];
}
close(GROUP);
open(PASSWD,'</etc/passwd') or die "Nie mozna otworzyc passwd!:$!";
while(<PASSWD>) {
chomp;
@passwd = split(':',$_);
print "$passwd[0]\n" if !exists $A{$passwd[0]};
}
close(PASSWD);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment