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::MessageID(3pm)					User Contributed Perl Documentation				     Email::MessageID(3pm)

NAME
Email::MessageID - Generate world unique message-ids. SYNOPSIS
use Email::MessageID; my $mid = Email::MessageID->new->in_brackets; print "Message-ID: $midx0Ax0D"; DESCRIPTION
Message-ids are optional, but highly recommended, headers that identify a message uniquely. This software generates a unique message-id. METHODS
new my $mid = Email::MessageID->new; my $new_mid = Email::MessageID->new( host => $myhost ); This class method constructs an Email::Address object containing a unique message-id. You may specify custom "host" and "user" parameters. By default, the "host" is generated from "Sys::Hostname::hostname". By default, the "user" is generated using "Time::HiRes"'s "gettimeofday" and the process ID. Using these values we have the ability to ensure world uniqueness down to a specific process running on a specific host, and the exact time down to six digits of microsecond precision. create_host my $domain_part = Email::MessageID->create_host; This method returns the domain part of the message-id. create_user my $local_part = Email::MessageID->create_user; This method returns a unique local part for the message-id. It includes some random data and some predictable data. in_brackets When using Email::MessageID directly to populate the "Message-ID" field, be sure to use "in_brackets" to get the string inside angle brackets: header => [ ... 'Message-Id' => Email::MessageID->new->in_brackets, ], Don't make this common mistake: header => [ ... 'Message-Id' => Email::MessageID->new->as_string, # WRONG! ], SEE ALSO
Email::Address, Time::HiRes, Sys::Hostname, perl. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project. <http://emailproject.perl.org/wiki/Email::MessageID> AUTHOR
Casey West, <casey@geeknest.com>. COPYRIGHT
Copyright (c) 2004 Casey West. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-07-15 Email::MessageID(3pm)