Intersection by part of the string


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Intersection by part of the string
# 8  
Old 04-10-2014
Quote:
Originally Posted by a_bahreini
Yeah that's because I'm only showing the first 10 lines. There are matches if I go down. Is there a way I can send you the files? Each of them has thousands lines.
Thanks
Out of the thousands of lines for each file, make a representative set that demonstrates most of the cases to be encountered.
If you want to attach the actual/squeezed files, use a 'paper-clip' icon in the upper row of the reply pane to attach files.
# 9  
Old 04-10-2014
Please see the attachment. You can take either as the first file and the other as the second
Thanks
# 10  
Old 04-10-2014
awk -f ab.awk FDA_Approved_drugs_names_sectioned.txt Drug-Gene_match_dgidb.txt where ab.awk is:
Code:
BEGIN {
  FS=OFS="\t"
}
FNR==NR {a[$1]=$0;next}
{
  for (i in a) {
    one=$1
    gsub("[][()]","\\\\&",one)
    if (tolower(i) ~ tolower(one) ) {
      print a[i], $0
      break
    }
  }
}

Be patient - it'll take some time to complete
This User Gave Thanks to vgersh99 For This Post:
# 11  
Old 04-10-2014
That works pretty well.
Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting a part of a string

Hi, I needed to extract some specific characters from a string based on user input. For example: After the script executes the user enters the following details: Please enter the string: This is a shell script Please enter the starting position: 11 Please enter the number of characters to be... (4 Replies)
Discussion started by: ChandanN
4 Replies

2. UNIX for Dummies Questions & Answers

Intersection by specific columns

Hi, I'd like to intersect two files by the 4th col of the first file and 6th col of the second file. This is the code I use: awk 'NR==FNR{A;next}$6 File1 File2 However, this is only outputting the second file lines. I'd like to have both lines in a single line separated by a tab. Thanks in... (25 Replies)
Discussion started by: a_bahreini
25 Replies

3. Shell Programming and Scripting

Finding intersection

Hi Friends, I would like to be helped for the following issue I am currently stuck with I have two files like the following tom ram 10 20 hey bye 11 12 bus cat 20 30 put but 25 30 jak mok 11 12 fil don 76 57 bus cat 23 45 pan ban 09 78 put but 45 67 kis mis 23 45 I would like... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

5. Shell Programming and Scripting

Need to take one part from a string

I have a string something like "/opt/src/default.cfg" OR /opt/src/common/one This whole string stored in an array. The problem is this string is not constant and it will keep on changing as lot of strings are stored in the array and it will be look like :- case 1 /opt/src/default.cfg ... (8 Replies)
Discussion started by: Renjesh
8 Replies

6. Web Development

Intersection and union of array by hash

Hi, A piece of script from Perl-cookbook I do not understand, and post here for explanation. The purpose is to find the element in either array (union), and in both array (intersection). Thank you in advance. @a=qw(1 3 5 6 7 8); @b=qw(2 3 5 7 9); foreach $e (@a, @b) {$union{$e}++ &&... (3 Replies)
Discussion started by: yifangt
3 Replies

7. Shell Programming and Scripting

Part of a string

Hi mates, I am doing a script in ksh. I have the following string: /opt/one/two/four/five/myFile.txt And I have a variable: echo "${variable}" -> /opt/one/two/ I would like to have just the string: four/five/myFile.txt What is the better way to do that? Thanks in... (3 Replies)
Discussion started by: gonzaloron
3 Replies

8. Shell Programming and Scripting

Getting part of a string

Hi, I have a string assinged to a varaible as below. FILE=/var/adm/message If $FILE is the value where it stores the path of message file. I would like to extract the location of the file message as below LOCATION=/var/adm FILE may have value like /var/adm/xxxx/message ... (2 Replies)
Discussion started by: raghu.amilineni
2 Replies

9. Shell Programming and Scripting

Find the intersection between two files

How can find the intersection between files for Example: file1 entry1 entry2 entry3 entry33 file2 entry2 entry4 entry5 . . . . the output should be entry2 (9 Replies)
Discussion started by: makrami
9 Replies

10. Shell Programming and Scripting

how to get the last part of a string followed by a pattern

assuming "cat" is the pattern, string (regardless length) asdadfcat4 I need to get 4 for eirtrjkkkcat678- I'd get 678 (in b-shell) Thanks in advance!!! (4 Replies)
Discussion started by: bluemoon1
4 Replies
Login or Register to Ask a Question