I want to sort my file by first column but I have to start sort from 5 character. How can I do that?
My file:
"TTTTCTTACA" 1 1
"TTTTCTTACC" 1
"TTTTCTTACT" 1 1
"TTTTCTTAGC" 1
"TTTTCTTATT" 2
"TTTTCTTCAA" 1 1 1
"TTTTCTTCAG" 1 2 1
"TTTTCTTCAT" 1 2 2
"TTTTCTTCCT" 2
"TTTTCTTCGG" 2 2
"TTTTCTTCTA" 1
"TTTTCTTCTG" 1
"TTTTCTTCTT" 1 2
"TTTTCTTGAA" 1
"TTTTCTTGCT" 1 1 1
"TTTTCTTTAA" 1
"TTTTCTTTAG" 1 1
"TTTTCTTTCT" 1
"TTTTCTTTGC" 1
"TTTTCTTTGG" 1 1
"TTTTCTTTGT" 1 1 2 1
"TTTTCTTTTA" 1
I was trying:
sort -k1,1 file | uniq -s 6 -w 5
Of course, it doesn't work. Mayby sort has some flags, but I didn't find them. Do you have some idea?
Best Answer
tl;dr
Explanation
My sort is GNU coreutils 8.22. The manpage for my sort shows:
So with your current sort command,
sort -k1,1 file
uses the first word to the first word as the sort.What you want is (for the sort command anyway):
This will use the fifth character of the first word, which is what you wanted.