blob: 8bccd1cfaafbd973b904e3eaba853dbbac415df1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long::Descriptive;
my @users = ();
my @pwent = ();
my ($opt, $usage) = describe_options(
'%c %o',
[ "name|n", "sort by name"],
[ "date|d", "sort by date"],
[ "reverse|r", "reverse sorting"],
[ 'help', "print usage message and exit" ],
);
if ( $opt->help ) {
print($usage->text);
exit;
};
while( @pwent = getpwent()) {
if( $pwent[2] >= 1000 && $pwent[2] < 65534 ) {
push( @users, "$pwent[0]\n" );
};
};
# sort by date kinda done by default
# maybe sort by time since last password change in /etc/shadow?
if ( $opt->name ) {
@users = sort( @users );
};
if ( $opt->reverse ) {
@users = reverse( @users );
};
print @users;
|