Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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:

Inf
-Inf
NA

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

1 Answer 1

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

 
discard

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.