perl -nle 'BEGIN{$l=shift} END{print $line} length == $l && $lc++ || next ; rand($lc) < 1 && ($line = $_)' 4 /usr/share/dict/words