awk command for printing all the repeated matching lines without making them unique
I have two files file1 file2 which has taxonomy details .
for example
file1 : ( it has taxonomy ID - some digit)
9
9
4
4
4
file2 : ( it has other taxonomy details along with taxonomy ID )
9 A B C D
4 P Q R S
I want to get an output like output :
9 A B C D
9 A B C D
4 P Q R S
4 P Q R S
4 P Q R S
I tried using this command
awk -F '\t' 'NR==FNR{a[$1];next} ($1) in a' file1 file2
• 1,947 views
•
link
2 answers
You don't need awk for this.
Following the data you shared here, just sort file1 and file2, and use join like so:
$ join -1 1 -2 1 <(sort file1) <(sort file2)
4 P Q R S
4 P Q R S
4 P Q R S
9 A B C D
9 A B C D
• 0 views
•
link
join -t $'\t' -1 1 -2 1 <(sort -t $'\t' -k1,1 file1) <(sort -t $'\t' -k1,1 file2)
• 0 views
•
link
Log in to answer this question.
how is it related to bioinformatics ?
I have two taxonomy data files , I am trying to map them with their taxID . and want to get all the repeated matched taxIDs along with other details.
Why
catintosed?