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

NAME
Email::Date - Find and Format Date Headers SYNOPSIS
use Email::Date; my $email = join '', <>; my $date = find_date($email); print $date->ymd; my $header = format_date($date->epoch); Email::Simple->create( header => [ Date => $header, ], body => '...', ); DESCRIPTION
RFC 2822 defines the "Date:" header. It declares the header a required part of an email message. The syntax for date headers is clearly laid out. Stil, even a perfectly planned world has storms. The truth is, many programs get it wrong. Very wrong. Or, they don't include a "Date:" header at all. This often forces you to look elsewhere for the date, and hoping to find something. For this reason, the tedious process of looking for a valid date has been encapsulated in this software. Further, the process of creating RFC compliant date strings is also found in this software. FUNCTIONS find_date my $time_piece = find_date $email; "find_date" accepts an email message in any format Email::Abstract can understand. It looks through the email message and finds a date, converting it to a Time::Piece object. If it can't find a date, it returns false. "find_date" is exported by default. format_date my $date = format_date; # now my $date = format_date( time - 60*60 ); # one hour ago "format_date" accepts an epoch value, such as the one returned by "time". It returns a string representing the date and time of the input, as specified in RFC 2822. If no input value is provided, the current value of "time" is used. "format_date" is exported by default. format_gmdate my $date = format_gmdate; "format_gmdate" is identical to "format_date", but it will return a string indicating the time in Greenwich Mean Time, rather than local time. "format_gmdate" is exported on demand, but not by default. PERL EMAIL PROJECT
This module is maintained by the Perl Email Project <http://emailproject.perl.org/wiki/Email::Date> SEE ALSO
Email::Abstract, Time::Piece, Date::Parse, perl. AUTHOR
Casey West, <casey@geeknest.com>. Ricardo SIGNES, <rjbs@cpan.org>. 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 2007-12-01 Email::Date(3pm)