Sorting file by column, with missing values
0
0
Entering edit mode
6.7 years ago
oars ▴ 200

I'm trying to sort a file by max values in column 8 (Raw), here is a sample of the data:

glimmer screen shoot

I tried to tackle this dataset with the following sort script:

sort -t$'\t' -k8,8  -nr glm_ref.detail2 > glm_ref_detail_sort

however, the output file keeps sorting on the first column? I removed the header info to simplify the process but for some reason it wants to sort on the ID column (column 1) which has many missing values. Any ideas?

Ideally the file will be sorted by Raw, starting with the max positive number and ending with the largest negative number.

glimmer sort awk • 1.7k views
ADD COMMENT
1
Entering edit mode

You'd need to head -2 <file> && tail -n +3 <file> | sort ... to sort properly. That header is super unwieldy.

ADD REPLY
1
Entering edit mode

Are you sure the file is tab-separated? You can check with cat -vet file.txt and see if columns are separated by the ^I marker. Also, you probably want -k8,8nr to sort column 8 numerically largest to smallest rather than alphanumerically.

ADD REPLY

Login before adding your answer.

Traffic: 1784 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6