BASH Finding Common Elements
2
0
Entering edit mode
3.6 years ago

Hello!

What is the best way to find common elements between 2 columns using BASH?

BASH • 735 views
ADD COMMENT
0
Entering edit mode

Of course, right as I post my answer below, you've edited the question and removed your reproducible example. That information should have been left in your post.

ADD REPLY
1
Entering edit mode
3.6 years ago

Biostars is not a code service - we generally will not provide code for you if you show no effort. In general, you should show what you tried and exactly what issues you're having. Here, you have at least provided a reproducible example, which is good. This is a fairly easy operation via awk (or many other methods) that can easily be found via google. As a warning, questions like this that show no effort may very well be closed in the future, but the following should work for you.

awk 'NR==FNR{c[$1]++;next};c[$1]' DEGs.txt all.genes.txt > output.txt

ADD COMMENT
0
Entering edit mode
3.6 years ago
Joe 21k

comm

ADD COMMENT
0
Entering edit mode

or diff or sdiff or cmp depending on what you look for

keep anyway in mind that all these linux commands assume you have sorted lists !

ADD REPLY

Login before adding your answer.

Traffic: 2711 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