The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Read a string with leading spaces and find the length of the string dayamatrix UNIX for Dummies Questions & Answers 2 11-13-2008 10:08 AM
regarding string length amitpansuria High Level Programming 10 10-05-2008 04:10 AM
length of string silas.john UNIX for Dummies Questions & Answers 8 02-06-2008 07:22 PM
read string, check string length and cut ozzy80 Shell Programming and Scripting 9 03-21-2007 05:56 PM
sed problem - replacement string should be same length as matching string. amangeles Shell Programming and Scripting 4 01-11-2006 06:11 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-19-2009
ad_meis ad_meis is offline
Registered User
  
 

Join Date: May 2009
Posts: 1
matching string in two files of different length

Dear all,
I have the following problem (it originates in the domain of bio-inf, but it is a general problem).

I have two files of one column each and of different length: a.txt and b.txt.
a.txt contains alphanumeric strings (around 30 digit) and there are 300 rows
b.txt contains alphanumeric strings (around 1000 digit) and there are 16 rows

I want to check (of course for every row) if the string in a.txt is contained by any of the 16 string in b.txt, and if it is the case print the corresponding (long) string of b.txt

I have tried with a "for" cycle and the gawk lines
Code:
for string_b in [... the 16 strings separated by a space  ...]; do 
        awk "{if (match(${string_b},/'\$1'/)){print '${string_b}' else {print 'nulla'}}" < string_a.txt > result
done
but it does not work (and in any case it is not very efficient or smart)

Many thanks! Any help or suggestion is welcome!
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:23 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0