Question: (Closed) how to fetch match string by comparing two files by using Shell or python
0
gravatar for Raghav
6.3 years ago by
Raghav100
Allahabad, India
Raghav100 wrote:

Dear All,

I need your help to correct me.

I have tow files named unique.txt and Total.txt.

unique.txt file contain two columns each columns are seprated by tab. Total.txt file contain: 3 colums each column seprated by tab.

what i do, take each rows from unique.txt file find that in total.txt file. if presnt 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 knw this is very poor attempt to resolve this problem. please help me to improve it nad reach upto 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 suggesstions

python shell programming • 2.5k views
ADD COMMENTlink written 6.3 years ago by Raghav100

What does this have to do with bioinformatics? BTW, you probably want ">> new_out.txt".
 

ADD REPLYlink written 6.3 years ago by Devon Ryan97k

Dear Sir,

 This is not directly related to bioinformatics.

ADD REPLYlink written 6.3 years ago by Raghav100

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!

ADD REPLYlink modified 6.3 years ago • written 6.3 years ago by Devon Ryan97k

I have got your point.

thank you Sir

ADD REPLYlink written 6.3 years ago by Raghav100
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1739 users visited in the last hour