how to fetch match string by comparing two files by using Shell or python
Dear All,
I need your help to correct me.
I have two files named unique.txt and Total.txt.
unique.txt file contain two columns each columns are separated by tab. Total.txt file contain: 3 columns each column separated by tab.
What I do, take each rows from unique.txt file find that in total.txt file. If present then extract entire row from total.txt and save it in new output file new_out.txt.
To do this I use shell script
#!/bin/bash
FILE=$1
while read line; do
egrep "$line" Total.txt > new_out.txt
done < $unique.txt
I know this is very poor attempt to resolve this problem. Please help me to improve it and reach up to optimal solution.
Please help out.
Unique.txt
mitochondria_205000_225000 mitochondria_195000_215000
mitochondria_345000_365000 mitochondria_335000_355000
mitochondria_345000_365000 mitochondria_5000_25000
chloroplast_115000_128207 chloroplast_35000_55000
chloroplast_115000_128207 chloroplast_15000_35000
mitochondria_185000_205000 mitochondria_25000_45000
2_16595000_16615000 2_16585000_16605000
4_2785000_2805000 4_2775000_2795000
4_11395000_11415000 4_11385000_11405000
4_2875000_2895000 4_2865000_2885000
4_13745000_13765000 4_13735000_13755000
Total.txt
interaction1 mitochondria_205000_225000 mitochondria_195000_215000
interaction2 mitochondria_345000_365000 mitochondria_335000_355000
interaction3 mitochondria_345000_365000 mitochondria_5000_25000
interaction4 chloroplast_115000_128207 chloroplast_35000_55000
interaction5 chloroplast_115000_128207 chloroplast_15000_35000
interaction15 2_10515000_10535000 2_10505000_10525000
Waiting for your valuable suggestions
• 2,974 views
•
link
0 answers
No answers yet.
Log in to answer this question.
What does this have to do with bioinformatics? BTW, you probably want
>> new_out.txt.Dear Sir,
This is not directly related to bioinformatics.
Hello Raghav!
We believe that this post does not fit the main topic of this site.
This is just a scripting question.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
I have got your point.
thank you Sir