in reply to Sort passwd by UID
use warnings; use strict; use File::Slurp; my $file = '/etc/passwd'; my @lines = read_file($file); chomp @lines; my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1] || $a->[1] cmp $b->[1]} map {[$_,(split':')[0]]} @lines; print "$_\n" for @sorted;
|
|---|