Things start out cheery, but quickly get ugly, $ for i in 9 99 999 9999 99999; do seq $i|sort -n|sed 5q|wc -l; done 5 5 5 5 sort: write failed: 'standard output': Broken pipe sort: write error 5 sort: write failed: 'standard output': Broken pipe sort: write error
Therefore, kindly add a sort --limit=n, and/or on (info "(coreutils) sort invocation") admit the problem, and give some workarounds, lest our scripts occasionally spew error messages seemingly randomly, just when the boss is looking. And no fair saying "just save the output" (could be big) "into a file first, and do head(1) or sed(1) on that."