awk: find smallest 10 values from column
<p>I have a file that is arranged like so:</p>

<pre><code>a  123
b 45
c -23
d 166
</code></pre>

<p>I'm new to awk and I want to find the ten (or x) lowest numbers in column 2 and print these rows in a new file.</p>

<p>Currently we use the following code and eyeball the results to see if we have roughly ten. If not, we change the -5.0 to something else and so on:</p>

<pre><code>cat input.txt | awk '{if($2 &lt; -5.0) {print $1" "$2}}' &gt;&gt; output.txt
</code></pre>