My plan was to sort the file by the UID, and then check for lines with UID = to previous line. Is this the best way?
Not necessarily. The common perl idiom for checking uniqueness is to iterate over all the values, and store the UID in a hash. If it existed before in the hash, it's not uniq. Consider:
my %uids; while (my $line = <$filehandle>) { my $uid = # extract from $line; if ($uids{$uid)) { print "'$uid' is duplicate\n" } else { $uids{$uid} = 1; } }
In reply to Re: Sort passwd by UID
by moritz
in thread Sort passwd by UID
by Saved
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |