Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a tab-separated ASCII file.

One of the columns contains numbers which always have a decimal point (like 0.311225363556077).

However, in this column entries might also be any one of these strings:


I would like to sort the lines of this file, by the value in that column. How can I do that?

I was thinking about using (GNU) sort, but I can't figure out if it recognizes Inf and -Inf properly.

The sort order should be: from top to bottom: Inf, numbers in order, -Inf, NA

This is on Debian.

share|improve this question
up vote 2 down vote accepted

Assume that the corresponding column is 2.

cat input |sort -k2 -g -r
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.