The UNIX and Linux Forums  


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
Perl: Instering Names in to Text. NDxiak Shell Programming and Scripting 6 07-20-2009 04:30 PM
Shell - Matching 3 letter file names PrasannaKS Shell Programming and Scripting 4 12-30-2008 02:37 PM
processing file names using text files ligander Shell Programming and Scripting 5 12-01-2008 06:32 PM
Text Matching aravindj80 UNIX for Dummies Questions & Answers 2 07-25-2008 07:47 AM
Simultaneous searching for files (names matching certain criteria) in several directo Hopeful AIX 0 02-13-2008 02:31 PM

Reply
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
  #1 (permalink)  
Old 08-25-2009
rider29 rider29 is offline
Registered User
  
 

Join Date: May 2008
Posts: 33
matching names in 2 text files

I have 2 text files like

________________________________

Company Name:yada yada
ADDRESS:some where, CITY,STATE
CONTACT PEOPLE:first_name1.last_name1,first_name2.last_name2,first_name3.last_name3
LEAD:first_name.last_name
________________________________
&

Data file2
______________________________
COMPANY NAME1:first_name.last_name, first_name1.last_name1,first_name2.last_name2,first_name3.last_name3
COMPANY NAME2:first_name4.last_name4, first_name5.last_name6,first_name7.last_name7,first_name8.last_name8


____________________________


I need to validate people(Bold) in

CONTACT PEOPLE:first_name1.last_name1,first_name2.last_name2,first_name3.last_name3
LEAD:first_name.last_name

against datafile 2 and make sure names in both files match.
(We can assume no name repetitions in data file2 )

i,e. .. I need to grep for each name in file1 against file2

Thank you all for your time

Last edited by rider29; 08-27-2009 at 04:58 PM..
  #2 (permalink)  
Old 08-31-2009
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
If you are just wanting to see if all the names liste in the first file are present in the second one:

Code:
for name in `egrep '^(CONTACT PEOPLE:|LEAD:) datafile1 | cut -d ':' -f 2 | sed 's/,/ /g'`
do
  if grep $name datafile2 > /dev/null
  then
    echo "$name validated"
  else
    echo "$name NOT VALIDATED"
  fi
done

(untested - try this somewhere safe and you may need to debug)
egrep is dependent on OS, if it's not present, try substituting with grep -e
Reply

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 09:32 PM.


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