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