This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to sort for unique values in a certain row?

How can I sort only the first column and only include unique values? ...I want the first three rows to only be 1. AT1G01080.

AT1G01080|AT1G01080.  286   0.975  0.048  0.003  0.037   C    1
AT1G01080|AT1G01080.  293   0.975  0.048  0.003  0.037   C    1
AT1G01080|AT1G01080.  294   0.975  0.048  0.003  0.037   C    1
AT1G01090|AT1G01090.  428   0.962  0.121  0.003  0.038   C    1
AT1G01250|AT1G01250.  192   0.736  0.079  0.031  0.246   C    3
AT1G01520|AT1G01520.  258   0.559  0.128  0.222  0.120   C    4
AT1G01520|AT1G01520.  287   0.559  0.128  0.222  0.120   C    4
AT1G01550|AT1G01550.  349   0.805  0.215  0.015  0.092   C    3
AT1G01690|AT1G01690.  450   0.685  0.105  0.005  0.160   C    3
AT1G01690|AT1G01690.  450   0.766  0.100  0.004  0.136   C    2
sequencing gene
sort -uk1,1 file

This worked for me

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted. Upvote|Bookmark|Accept

1 answer

look at option -u of sort ... http://man7.org/linux/man-pages/man1/sort.1.html

Log in to answer this question.