Sponsored Content
Top Forums UNIX for Dummies Questions & Answers compare two files based on common field in unix Post 302579850 by tarun_agrawal on Tuesday 6th of December 2011 09:49:27 PM
Old 12-06-2011
try with awk..
Code:
awk -F"|" 'NR==FNR{a[$0];next} ($1 in a) {print $0} ' Entity Reference

Note: if you are using join, you must use sorted input.

Last edited by Franklin52; 12-07-2011 at 05:27 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merge files of differrent size with one field common in both files using awk

hi, i am facing a problem in merging two files using awk, the problem is as stated below, file1: A|B|C|D|E|F|G|H|I|1 M|N|O|P|Q|R|S|T|U|2 AA|BB|CC|DD|EE|FF|GG|HH|II|1 .... .... .... file2 : 1|Mn|op|qr (2 Replies)
Discussion started by: shashi1982
2 Replies

2. Shell Programming and Scripting

How to append two files with common field.

I have two files like File1 : will get this file from "who" command. It is a unix file. user val1 Jul 29 13:15 (IP Address1) user val3 Jul 30 03:21 (IP Address2) user val2 Jul 29 13:16 (IP Address3) user val4 Jul 29 13:17 (IP Address4) ... (4 Replies)
Discussion started by: manneni prakash
4 Replies

3. Shell Programming and Scripting

join files based on a common field

Hi experts, Would you please help me with this? I have several files and I need to join the forth field of them based on the common first field. here's an example... first file: 280346 39.88 -75.08 547.8 280690 39.23 -74.83 538.7 280729 40.83 -75.08 499.2 280907 40.9 -74.4 507.8... (5 Replies)
Discussion started by: GoldenFire
5 Replies

4. 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

5. Shell Programming and Scripting

Merging CSV fields based on a common field

Hi List, I have two files. File1 contains all of the data I require to be processed, and I need to add another field to this data by matching a common field in File2 and appending a corresponding field to the data in File1 based on the match... So: File 1:... (1 Reply)
Discussion started by: landossa
1 Replies

6. Shell Programming and Scripting

Matching and Merging csv data fields based on a common field

Dear List, I have a file of csv data which has a different line per compliance check per host. I do not want any omissions from this csv data file which looks like this: date,hostname,status,color,check 02-03-2012,COMP1,FAIL,Yellow,auth_pass_change... (3 Replies)
Discussion started by: landossa
3 Replies

7. Shell Programming and Scripting

Compare a common field in two files and append a column from File 1 in File2

Hi Friends, I am new to Shell Scripting and need your help in the below situation. - I have two files (File 1 and File 2) and the contents of the files are mentioned below. - "Application handle" is the common field in both the files. (NOTE :- PLEASE REFER TO THE ATTACHMENT "Compare files... (2 Replies)
Discussion started by: Santoshbn
2 Replies

8. 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

9. Shell Programming and Scripting

Compare multiple files, and extract items that are common to ALL files only

I have this code awk 'NR==FNR{a=$1;next} a' file1 file2 which does what I need it to do, but for only two files. I want to make it so that I can have multiple files (for example 30) and the code will return only the items that are in every single one of those files and ignore the ones... (7 Replies)
Discussion started by: castrojc
7 Replies

10. UNIX for Beginners Questions & Answers

Compare two files and print based on common variable value.

Hi All, i have below two files. FILE: NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root" GROUP="disk" MODE="brw-rw----" PKNAME="" MOUNTPOINT="" NAME="/dev/sda1" TYPE="part" SIZE="500M" OWNER="root" GROUP="disk" MODE="brw-rw----" PKNAME="/dev/sda" MOUNTPOINT="/boot" NAME="/dev/sda2"... (3 Replies)
Discussion started by: balu1234
3 Replies
Mail::GnuPG(3pm)					User Contributed Perl Documentation					  Mail::GnuPG(3pm)

NAME
Mail::GnuPG - Process email with GPG. SYNOPSIS
use Mail::GnuPG; my $mg = new Mail::GnuPG( key => 'ABCDEFGH' ); $ret = $mg->mime_sign( $MIMEObj, 'you@my.dom' ); DESCRIPTION
Use GnuPG::Interface to process or create PGP signed or encrypted email. new Create a new Mail::GnuPG instance. Arguments: Paramhash... key => gpg key id keydir => gpg configuration/key directory passphrase => primary key password use_agent => use gpg-agent if non-zero always_trust => always trust a public key # FIXME: we need more things here, maybe primary key id. decrypt Decrypt an encrypted message Input: MIME::Entity containing email message to decrypt. The message can either be in RFC compliant-ish multipart/encrypted format, or just a single part ascii armored message. Output: On Failure: Exit code of gpg. (0 on success) On Success: (just encrypted) (0, undef, undef) On success: (signed and encrypted) ( 0, keyid, # ABCDDCBA emailaddress # Foo Bar <foo@bar.com> ) where the keyid is the key that signed it, and emailaddress is full name and email address of the primary uid $self->{last_message} => any errors from gpg $self->{plaintext} => plaintext output from gpg $self->{decrypted} => parsed output as MIME::Entity get_decrypt_key determines the decryption key (and corresponding mail) of a message Input: MIME::Entity containing email message to analyze. The message can either be in RFC compliant-ish multipart/signed format, or just a single part ascii armored message. Output: $key -- decryption key $mail -- corresponding mail address verify verify a signed message Input: MIME::Entity containing email message to verify. The message can either be in RFC compliant-ish multipart/signed format, or just a single part ascii armored message. Note that MIME-encoded data should be supplied unmodified inside the MIME::Entity input message, otherwise the signature will be broken. Since MIME-tools version 5.419, this can be achieved with the C<decode_bodies> method of MIME::Parser. See the MIME::Parser documentation for more information. Output: On error: Exit code of gpg. (0 on success) On success ( 0, keyid, # ABCDDCBA emailaddress # Foo Bar <foo@bar.com> ) where the keyid is the key that signed it, and emailaddress is full name and email address of the primary uid $self->{last_message} => any errors from gpg has_public_key Does the keyring have a public key for the specified email address? FIXME: document better. talk about caching. maybe put a better interface in. mime_sign sign an email message Input: MIME::Entity containing email message to sign Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be signed. (i.e. it _will_ be modified.) clear_sign clearsign the body of an email message Input: MIME::Entity containing email message to sign. This entity MUST have a body. Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be signed. (i.e. it _will_ be modified.) ascii_encrypt encrypt an email message body using ascii armor Input: MIME::Entity containing email message to encrypt. This entity MUST have a body. list of recipients Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be encrypted. (i.e. it _will_ be modified.) ascii_signencrypt encrypt and sign an email message body using ascii armor Input: MIME::Entity containing email message to encrypt. This entity MUST have a body. list of recipients Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be encrypted. (i.e. it _will_ be modified.) mime_encrypt encrypt an email message Input: MIME::Entity containing email message to encrypt list of email addresses to sign to Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be encrypted. (i.e. it _will_ be modified.) mime_signencrypt sign and encrypt an email message Input: MIME::Entity containing email message to sign encrypt list of email addresses to sign to Output: Exit code of gpg. (0 on success) $self->{last_message} => any errors from gpg The provided $entity will be encrypted. (i.e. it _will_ be modified.) is_signed best guess as to whether a message is signed or not (by looking at the mime type and message content) Input: MIME::Entity containing email message to test Output: True or False value is_encrypted best guess as to whether a message is signed or not (by looking at the mime type and message content) Input: MIME::Entity containing email message to test Output: True or False value LICENSE
Copyright 2003 Best Practical Solutions, LLC This program is free software; you can redistribute it and/or modify it under the terms of either: a) the GNU General Public License as published by the Free Software Foundation; version 2 http://www.opensource.org/licenses/gpl-license.php b) the "Artistic License" http://www.opensource.org/licenses/artistic-license.php This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details. AUTHOR
Robert Spier David Bremner <ddb@cpan.org> BUGS
/ISSUES/PATCHES Please send all bugs/issues/patches to bug-Mail-GnuPG@rt.cpan.org SEE ALSO
perl. GnuPG::Interface, MIME::Entity perl v5.14.2 2011-12-12 Mail::GnuPG(3pm)
All times are GMT -4. The time now is 01:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy