At 3:46 PM +0100 2007/01/25, Jan Erik Moström wrote:
Reply to Jason R. Finley <[EMAIL PROTECTED]> 07-01-25 07:53:

I've looked high and low but can't figure out how to easily do this: I
have two text files.  In the first is a list of words (one word per
line), and for EACH of those words, I have to search and see if it
exists in the second text file.  How can I automate this?  (preferably
without reinventing the wheel) thanks very much,

Something like this might work

#!/usr/bin/perl -w

The simple shell script to search 'searchme' for each word in 'words' is:

[EMAIL PROTECTED]:~$ for w in `cat words`; do echo ; echo "$w:"; grep $w searchme; done

test:
is a test
test

nomatch:
[EMAIL PROTECTED]:~$ cat words
test
nomatch
[EMAIL PROTECTED]:~$ cat searchme
this
is a test
test


                                                Chris
--
Chris Pepper:               <http://www.reppep.com/~pepper/>
                            <http://www.extrapepperoni.com/>
Rockefeller University:     <http://www.rockefeller.edu/>

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to