Created
June 30, 2011 00:11
-
-
Save dbb/1055330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010; | |
open (my $in, '<', '/etc/passwd'); | |
my %passwd; | |
while (<$in>) { | |
if ( /^(\w+):([\w:\/]+)$/ ) { | |
my $key = $1; | |
my $val = $2; | |
$val =~ s/:+/\ /g; | |
$passwd{ $key } = $val; | |
} | |
} | |
while ( my ($key, $val) = each(%passwd)){ | |
say "'$key' => '$val'"; | |
} |
while (<$in>) {
s/[\w/:]//g;
say unless /^\s+$/;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'games' => 'x 5 60 games /usr/games /bin/sh'
'libuuid' => 'x 100 101 /var/lib/libuuid /bin/sh'
'bin' => 'x 2 2 bin /bin /bin/sh'
'cavia' => 'x 1001 1001 /home/cavia /bin/bash'
'nobody' => 'x 65534 65534 nobody /nonexistent /bin/sh'
'lp' => 'x 7 7 lp /var/spool/lpd /bin/sh'
'statd' => 'x 104 65534 /var/lib/nfs /bin/false'
'irc' => 'x 39 39 ircd /var/run/ircd /bin/sh'
'root' => 'x 0 0 root /root /bin/zsh4'
'mail' => 'x 8 8 mail /var/mail /bin/sh'
'backup' => 'x 34 34 backup /var/backups /bin/sh'
'daemon' => 'x 1 1 daemon /usr/sbin /bin/sh'
'ntp' => 'x 106 112 /home/ntp /bin/false'
'messagebus' => 'x 101 105 /var/run/dbus /bin/false'
'uucp' => 'x 10 10 uucp /var/spool/uucp /bin/sh'
'sys' => 'x 3 3 sys /dev /bin/sh'
'sync' => 'x 4 65534 sync /bin /bin/sync'
'man' => 'x 6 12 man /var/cache/man /bin/sh'
'news' => 'x 9 9 news /var/spool/news /bin/sh'
'sshd' => 'x 102 65534 /var/run/sshd /usr/sbin/nologin'
'proxy' => 'x 13 13 proxy /bin /bin/sh'