in reply to Re: traverse through passwd file, and split fields to extract UID/GID
in thread traverse through passwd file, and split fields to extract UID/GID
my $HAN = "handle"; my $FILE = "passwd.txt"; open("$HAN", "$FILE")||die "Error opening file: $!\n"; while(<$HAN>) { my ($name,$passwd,$uid,$gid,$gcos,$dir,$shell) = split(/:/,$_); print "UID is: $uid\n"; print "GID is: $gid\n"; } close("$HAN");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: traverse through passwd file, and split fields to extract UID/GID
by kcott (Archbishop) on Apr 23, 2014 at 13:46 UTC |