How to compare 2 field from 2 separated file

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications How to compare 2 field from 2 separated file
# 1  
Old 09-19-2011
How to compare 2 field from 2 separated file

I have a problem here. I'm trying to compare multiple fields. Files are like this:

File 1:

Email,Account Number,Contact,Status,Date

File 2:

Name|Address|Contact|Email|Account Number|0000000


Code:
#!/bin/bash

myFolder=`pwd`
TEMPFILE=$myFolder/tempfile

APFILE=$myFolder/file 1.csv
APID=$myFolder/file 1.src

AAPFILE=`ls $myFolder/$1`
AAPID=$myFolder/file 2.src
AAPID2=$myFolder/file 2.src

AAPXAP=$myFolder/Result.csv

if [ -f $APFILE -a -f $AAPFILE ]
then
 cat $APFILE | cut -f1 -d, | sed 's/ //g' | sort | uniq > $APID
 cat $AAPFILE | cut  -f37 -d"|" | sort | uniq > $AAPID
 comm -23 $AAPID $APID > $AAPXAP

 echo "AAP vs AP done!"
fi


Thank You

Last edited by pludi; 09-19-2011 at 03:57 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Compare at field level

Hi, I am trying to compare two fixed width files as shown below. The file is NOT sorted. The field in bold red is the key field. The comparison needs to be based of key fields and not whole record. But needs to write out the whole record in the output. OldFile.txt: A100135123456789 ... (5 Replies)
Discussion started by: Saanvi1
5 Replies

2. UNIX for Dummies Questions & Answers

Help with AWK - Compare a field in a file to lookup file and substitute if only a match

I have the below 2 files: 1) Third field from file1.txt should be compared to the first field of lookup.txt. 2) If match found then third field, file1.txt should be substituted with the second field from lookup.txt. 3)Else just print the line from file1.txt. File1.txt:... (4 Replies)
Discussion started by: venalla_shine
4 Replies

3. Shell Programming and Scripting

Plz Help. Compare 2 files field by field and get the output in another file.

Hi Freinds, I have 2 files . one is source.txt and second one is target.txt. I want to keep source.txt as baseline and compare target.txt. please find the data in 2 files and Expected output. Source.txt 1|HYD|NAG|TRA|34.5|1234 2|CHE|ESW|DES|36.5|134 3|BAN|MEH|TRA|33.5|234... (5 Replies)
Discussion started by: i150371485
5 Replies

4. Shell Programming and Scripting

Compare two files Field by field and output the result in another file

Hi Friends, Need Help. I have file1.txt as File1.txt |123|A|7267|Hyder|Cross|Sell|7801 |995|A|7051|2008|Lunar|New|Year|Promotion|7801 |996|A|7022|Q108|Targ|Prospect|&|SSCC|Savings|Promo|7801 |997|A|7182|Q1|Feb-Apr|08|Credit|ITA|PA|SBA|Campaign|7801 File2.txt... (7 Replies)
Discussion started by: i150371485
7 Replies

5. Shell Programming and Scripting

Text file to CSV with field data separated by blank lines

Hello, I have some data in a text file where fields are separated by blank lines. There are only 6 fields however some fields have several lines of data as I will explain. Also data in a particular field is not consistently the same size but does end on a blank line. The first field start with... (6 Replies)
Discussion started by: vestport
6 Replies

6. Shell Programming and Scripting

Inserting string in between field in comma separated file

Hello Mates, I have one txt file having commo seperated values. I have to insert string "FALSE" in 2nd field from the end. E.G SE18 6RN,,,,5439070,1786840,,1000002148671600,123434 Out put should be: SE18 6RN,,,,5439070,1786840,FALSE,1000002148671600,123434 Can some one help me to... (8 Replies)
Discussion started by: krsnadasa
8 Replies

7. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

8. Shell Programming and Scripting

Compare Tab Separated Field with AWK to all and print lines of unique fields.

Hi. I have a tab separated file that has a couple nearly identical lines. When doing: sort file | uniq > file.new It passes through the nearly identical lines because, well, they still are unique. a) I want to look only at field x for uniqueness and if the content in field x is the... (1 Reply)
Discussion started by: rocket_dog
1 Replies

9. Shell Programming and Scripting

Compare two columns separated by a tab

witam potrzebuje polecenia porownujacego koumny na podstawie n-ostatnich znakow danej linnijki tj mam 2 koumny AiB zawierajace ciag dowolnych znakow (dlugosci w kazdej linijce mga byc rozne wiec uzycie substra odpada) A B ewewewabc nbgujnnabc... (3 Replies)
Discussion started by: Toudi
3 Replies

10. Shell Programming and Scripting

How to format file into comma separated field

Guys, Need you help, i have a a file content that look like this. Nokia 3330 <spaces><spaces><more spaces>+76451883874 Nokia 3610 +87467361615 so on and so forth, - there are so many spaces in between. - e.g.... (5 Replies)
Discussion started by: shtobias
5 Replies
Login or Register to Ask a Question
Email::Thread(3pm)					User Contributed Perl Documentation					Email::Thread(3pm)

NAME
Email::Thread - Use JWZ's mail threading algorithm with Email::Simple objects SYNOPSIS
use Email::Thread; my $threader = Email::Thread->new(@messages); $threader->thread; dump_em($_,0) for $threader->rootset; sub dump_em { my ($self, $level) = @_; debug (' \-> ' x $level); if ($self->message) { print $self->message->header("Subject") , " "; } else { print "[ Message $self not available ] "; } dump_em($self->child, $level+1) if $self->child; dump_em($self->next, $level) if $self->next; } DESCRIPTION
Strictly speaking, this doesn't really need Email::Simple objects. It just needs an object that responds to the same API. At the time of writing the list of classes with the Email::Simple API comprises just Email::Simple. Due to how it's implemented, its API is an exact clone of Mail::Thread. Please see that module's documentation for API details. Just mentally substitute "Email::Thread" everywhere you see "Mail::Thread" and "Email::Thread::Container" where you see "Mail::Thread::Container". PERL EMAIL PROJECT
This module is maintained by the Perl Email Project. <http://emailproject.perl.org/wiki/Email::Thread> SUPPORT
Support for this module is provided via the CPAN RT system at <http://rt.cpan.org/> LICENCE AND COPYRIGHT
Copyright X Iain Truskett, 2003. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. THANKS
Simon Cozens (SIMON) for encouraging me to release it, and for Email::Simple and Mail::Thread. Richard Clamp (RCLAMP) for the header patch. AUTHORS
Iain Truskett <spoon@cpan.org> SEE ALSO
perl, Mail::Thread, Email::Simple perl v5.10.0 2007-03-22 Email::Thread(3pm)