Print all the linux system users that starts with d or D
Answer
- With a Perl one liner :D
open(my $fh, ';
map { print $& . "\n" if $_ =~ /^d([^:]*)/ } @user_info;
close $fh;
- Avoiding one-liners
foreach my $user_line (@user_info) {
if ($user_line =~ /^d([^:]*)/) {
print $& . "\n";
}
}