<html style="direction: ltr;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<div class="moz-cite-prefix">On 09/11/2012 05:23 PM, Assaf Gordon
wrote:<br>
</div>
<blockquote cite="mid:504F4967.9050509@cshl.edu" type="cite"><br>
<pre wrap="">
Here's another solution, even shorter (if you're willing to accept mixing ls, shell pipes and perl):
===
ls | perl -sne '$a{length($_)}=$_;END{map{print $a{$_}}(1..$N+1)}' -- -N=5
===
</pre>
</blockquote>
FINALLY, a one-liner that uses a perl flag other than -e!<br>
<br>
Although it generates different output than the other programs -
with file names that have identical length, it prints the last, not
the first (alphabetically) - so it should probably be
$a{length($_)}||=$_<br>
<br>
The big bug is it doesn't actually print the first N file names, it
prints the file names with lengths between 1..N <br>
So if the shortest name is more than 1 character, or some slots are
missing...<br>
<br>
<br>
<br>
<br>
<br>
<br />--
<br />This message has been scanned for viruses and
<br />dangerous content by
<a href="http://www.mailscanner.info/"><b>MailScanner</b></a>, and is
<br />believed to be clean.
</body>
</html>