perl -F: -lane 'push @x, $F[0] if /^[A-Z]/}{print for sort @x' infile