Sponsored Content
Top Forums Shell Programming and Scripting script to compare two columns in a file Post 302550203 by sasharma on Thursday 25th of August 2011 02:51:08 AM
Old 08-25-2011
script to compare two columns in a file

Dear everyone,
I need any sort of shell script or perl script would do the following. I have a txt file as follows:
;Stretnumber Resident Resdient (not in file)
Code:
   16  John        Mary       
   16  Mary        Parker
   16  Nancy       Smith
   16  Mary        John
   18  Trey        Steve
   20  Mandy       Greg
   22  Mary        John

I want to remove duplicate entries i.e., line 1 (John Mary) and line 4 (Mary John). Line 7 also has Mary John, but a different street. So I want the file to be printed as:
Code:
   16  John        Mary       
   16  Mary        Parker
   16  Nancy       Smith
   18  Trey        Steve
   20  Mandy       Greg
   22  Mary        John

Thanks for help!

Last edited by Franklin52; 08-25-2011 at 05:55 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

compare file columns

I need help in file comparision. I have two files in below format: FILE_A: ------- COL1 COL2 COL3 COL4 COL5 FILE_B: ------- COL1A COL1B COL1C COL1D COL1E i want to compare for a for each row in FILE_A and FILE_B COL1 of FILE_A with COL1B of FILE_B COL3 of FILE_A with COL1E of... (1 Reply)
Discussion started by: learnoutmore99
1 Replies

2. Shell Programming and Scripting

Compare selected columns from a file and print difference

I have learned file comparison from my previous post here. Then, it is comparing the whole line. Now, i have a new problem. I have two files with 3 columns separated with a "|". What i want to do is to compare the second and third column of file 1, and the second and third column of file 2. And... (4 Replies)
Discussion started by: kingpeejay
4 Replies

3. Shell Programming and Scripting

compare two columns of different files and print the matching second file..

Hi, I have two tab separated files; file1: S.No ddi fi cu o/l t+ t- 1 0.5 0.6 o 0.1 0.2 2 0.2 0.3 l 0.3 0.4 3 0.5 0.8 l 0.1 0.6 ... (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

4. Shell Programming and Scripting

Compare data and columns script

Hello all, I have below SQLs to compare data between 2 identical tables.in my database. Can any body help me to convert this into a script db2 "select *from TAB1 where PK IN (select PK from TAB2) order by BEDG_NR". Note: These SQL should run for any given 2 tables as input TAB1... (4 Replies)
Discussion started by: kanakaraju
4 Replies

5. UNIX for Dummies Questions & Answers

To compare first two columns in an excel file

Hi All, i have a excel sheet with two columns as below. column1 column2 100 100 200 300 300 400 400 400 500 600 i need to compare the values these two columns and the output should be printed in the third column...if these values are equal the output should be green and if these... (2 Replies)
Discussion started by: arunmanas
2 Replies

6. Shell Programming and Scripting

Compare Multiple Columns in one file

Hello guys, I am quite new to Shell Scripting and I need help for this I have a CSV file like this: Requisition,Order,RequisitionLineNumber,OrderLineNumber REQ1,Order1,1,1 REQ1,Order1,1,3 REQ2,Order2,1,5 Basically what I want to do is compare the first 3 fields If all 3 fields are the same... (5 Replies)
Discussion started by: jeffreybsu
5 Replies

7. Shell Programming and Scripting

Compare two date columns in same file

Hi All, Need to compare two date columns from the filname FinalDate.txt. My data's are like below D_OT_START D_EXP_STR Amount 1/3/2012 1/3/2012 5000 6/21/2011 6/25/2011 6000 2/28/2011 2/28/2011 7000 7/16/2010 8/16/2010 8000 7/14/2010 10/26/2010 9000 ... (3 Replies)
Discussion started by: suresh_target
3 Replies

8. Shell Programming and Scripting

Compare columns in a single file

i have the following files (all separated by tabs): file 1.txt 1 yes 2 no 3 yes 4 yes file 2.txt a no b no c yes d no i combine the above files in file 3 which looks like file 3.txt 1 yes a no 2 no b no 3 yes c yes 4 yes d no now, i need to compare the values between column 2... (3 Replies)
Discussion started by: msonoth
3 Replies

9. Shell Programming and Scripting

Compare 2 columns from the same file and print a value depending on the result

Hello Unix gurus, I have a file with this format (example values): label1 1 0 label2 1 0 label3 0.4 0.6 label4 0.5 0.5 label5 0.1 0.9 label6 0.9 0.1 in which: column 1 is a row label column 2 and 3 are values I would like to do a simple operation on this table and get the... (8 Replies)
Discussion started by: ksennin
8 Replies

10. UNIX for Beginners Questions & Answers

Awk: compare values in two columns of the same file

I'm trying to learn awk, but I've hit a roadblock with this problem. I have a hierarchy stored in a file with 3 columns: id name parentID 4 D 2 2 B 1 3 C 1 1 A 5 I need to check if there are any values in column 3 that are not represented anywhere in column 1. I've tried this: awk '{arr;}... (7 Replies)
Discussion started by: kaktus
7 Replies
HTML::Microformats::Format::XFN(3pm)			User Contributed Perl Documentation		      HTML::Microformats::Format::XFN(3pm)

NAME
HTML::Microformats::Format::XFN - the XFN microformat SYNOPSIS
use Data::Dumper; use HTML::Microformats::DocumentContext; use HTML::Microformats::Format::XFN; my $context = HTML::Microformats::DocumentContext->new($dom, $uri); my @links = HTML::Microformats::Format::XFN->extract_all( $dom->documentElement, $context); foreach my $link (@links) { printf("<%s> %s ", $link->get_href, join(" ", $link->get_rel)); } DESCRIPTION
HTML::Microformats::Format::XFN inherits from HTML::Microformats::Format. See the base class definition for a description of property getter/setter methods, constructors, etc. Additional Public Methods "$xfn->subject_hcard" Returns the hCard for the subject of the relationship. e.g. if Mary has parent Sue, then Mary is the subject. If the subject could not be determined, may return undef. "$xfn->object_hcard" Returns the hCard for the object of the relationship. e.g. if Mary has parent Sue, then Sue is the object. The person that is the object of the relationship may not have an hCard on this page, or the parser may not be able to determine the correct hCard, in which case, may return undef. MICROFORMAT
HTML::Microformats::Format::XFN supports XHTML Friends Network 1.0 and 1.1 as described at <http://gmpg.org/xfn/1> and <http://gmpg.org/xfn/11>; plus the relationship profile described at <http://purl.org/vocab/relationship/>; and XHTML Enemies Network 1.0 as described at <http://xen.adactio.com/>. By default, only XFN 1.1 is parsed, but if the context has profiles matching the other URIs above, then the other vocabularies are supported. RDF OUTPUT
Data is returned using the DERI's XFN vocabulary (<http://vocab.sindice.com/xfn#>) and when appropriate, Ian Davis' RDF relationship vocab (<http://purl.org/vocab/relationship/>) and Toby Inkster's XEN vocab (<http://buzzword.org.uk/rdf/xen#>). BUGS
Please report any bugs to <http://rt.cpan.org/>. SEE ALSO
HTML::Microformats::Format, HTML::Microformats, HTML::Microformats::Format::hCard. AUTHOR
Toby Inkster <tobyink@cpan.org>. COPYRIGHT
Copyright 2008-2011 Toby Inkster This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. perl v5.14.2 2011-12-06 HTML::Microformats::Format::XFN(3pm)
All times are GMT -4. The time now is 02:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy