 <p>Here's one <code>bash</code> solution (assuming the numbers are in a file, one per line):</p> <pre><code>sort -n numbers.txt | grep -n . | grep -v -m1 '\([0-9]\+\):\1' | cut -f1 -d: </code></pre> <p>The first part sorts the numbers and then adds a sequence number to each one, and the second part finds the first sequence number which doesn't correspond to the number in the array.</p> <p>Same thing, using sort and awk (bog-standard, no extensions in either):</p> <pre><code>sort -n numbers.txt | awk '$1!=NR{print NR;exit}' </code></pre>