interesting. remove n numeric works. and works very well
• 0 views
•
link
Hi All,
I want to sort P-values in bash with sort command. The P-values are as the following:
A 1.14e-06
B 4.35e-05
C 0.5361
D 0.7278
When you use sort -k2n,2 input.txt, the result is as the following:
C 0.5361
D 0.7278
A 1.14e-06
B 4.35e-05
I tried sort -gk2n,2 input.txt and not working neither.
Anyone can share a correct bash or Perl one-line command to sort them correctly.
Thanks.
$ sort -g -k2 list
A 1.14e-06
B 4.35e-05
C 0.5361
D 0.7278
interesting. remove n numeric works. and works very well
Using both g and n at the same time gives an error:
$ sort -gn input.txt
sort: options '-gn' are incompatible
Or:
$ sort -k2ng,2 input.txt
sort: options '-gn' are incompatible
I am guessing, in your case it doesn't throw an error as we are using g for all columns and n for the second column.
Log in to answer this question.