Sponsored Content
Top Forums Shell Programming and Scripting compare 2 coloum of 2 diff files using perl script Post 302219740 by era on Wednesday 30th of July 2008 01:37:05 AM
Old 07-30-2008
And here is (roughly) the same in Perl:

Code:
perl -ane 'BEGIN { open FILE1, ">file1.both"; open FILE2, ">file2.both"; }
  if ($. == ++$n) { $h{$F[2]} = $_; close ARGV if eof; next; }
  if ($h{$F[2]}) { print FILE1 $h{$F[2]}; print FILE2; }' file1 file2

This isn't very idiomatic Perl, but should hopefully be enough to get you started. The trickery with $n and ARGV is to simulate the awk NR==FNR idiom. The eof thing is to reset line numbers in $. when the file changes; see the eof documentation for a brief discussion.

By the way, $3 in 6515152 52272 * ConstMethodKlass is just "*" -- maybe you want to normalize that, rather than change the script.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two files and output diff to third file

I have made several attempts to read two files of ip addresses and eliminate records from file1 that are in file2. My latest attempt follows. Everything works except my file3 is exactly the same as file1 and it should not be. # !/usr/bin/bash # # NoInterfaces # Utility will create a file... (8 Replies)
Discussion started by: altamaha
8 Replies

2. Shell Programming and Scripting

add coloum value based on first coloum

Hi i have a file and i want to add the coloum values like 9067 is coming twice here so o/p willbe like 9067,sum of 3rd coloum,sum of 4th coloum 9015 is coming 0nce then o/p 9015,15,6 sum is happening based on first coloum it will add all the third coloum and 4th coloum value where first... (1 Reply)
Discussion started by: aaysa123
1 Replies

3. Shell Programming and Scripting

compare two files, diff the result

Hi Everyone, 1.txt 00:01:01 asdf 00:33:33 1234 00:33:33 0987 00:33:33 12 00:33:33 444 2.txt vvvv|ee 444|dd33|ee dddd|ee 12|ee 3ciur|fdd the output should be: (6 Replies)
Discussion started by: jimmy_y
6 Replies

4. Shell Programming and Scripting

Using Diff to Compare 2 files

Hi I've been trying various methods that I have found online with regards to comparing 2 files using the diff command. Nothing seems to work. The problem is that I'm not too familiar with the proper syntax. Can you please assist me. Here is my script: #!/bin/bash awk -F',' -v file1="$1"... (9 Replies)
Discussion started by: ladyAnne
9 Replies

5. Shell Programming and Scripting

Perl script to compare two files

hi, As such I am new to perl on google search I found a code for Perl script to compare two files and print differences between them and instead of prinintg I want to store the diff. in a outputfile so can sombody provide assistance upon this from where can I edit in script to store the diff in... (1 Reply)
Discussion started by: dinesh.4126
1 Replies

6. Shell Programming and Scripting

Need Perl script to compare two CSV files

Need perl script to compare the two CSV files and and give out put in CSV format File MsPMTP.csv File ProfileNames.csv MsPMTP.csv is having lines like below JBL_VIJ_A_A962/r01sr4sl12/port#01-#13-Au4P-4c-TMi-PMNETR15 JBL_VIJ_A_A962/r01sr4sl12/port#01-#13-Au4P-4c-TMi-PMFETR15... (9 Replies)
Discussion started by: sreedhargouda
9 Replies

7. Shell Programming and Scripting

Shell script to compare ,diff and remove betwen 2 files

Hi Friends Need your expertise. Command to check the difference and compare 2 files and remove lines . example File1 is master copy and File2 is a slave copy . whenever i change, add or delete a record in File1 it should update the same in slave copy . Can you guide me how can i accomplish... (3 Replies)
Discussion started by: ajayram_arya
3 Replies

8. Shell Programming and Scripting

Compare two CSV files and put the difference in third file with line no,field no and diff value.

I am having two csv files i need to compare these files and the output file should have the information of the differences at the field level. For Example, File 1: A,B,C,D,E,F 1,2,3,4,5,6 File 2: A,C,B,D,E,F 1,2,4,5,5,6 out put file: (12 Replies)
Discussion started by: karingulanagara
12 Replies

9. Shell Programming and Scripting

Diff of 2 files using perl

Assitance needed in checking file difference using a perl script Below is the example I wanted a report saying file2 has an update of new value. File1 old date Alpha 156 Beta 255 Gama 6987 segma 4578 File2 new date Alpha 156 Beta 255 Gama 1000 (3 Replies)
Discussion started by: ajayram_arya
3 Replies
INN::Config(3pm)					    InterNetNews Documentation						  INN::Config(3pm)

NAME
Config.pm - Export all the variables an INN Perl script might need DESCRIPTION
This Perl module sets up any and all the variables that an INN Perl script might need. More particularly, it allows to use inn.conf variables: they are all provided by innconfval, as well as the version of INN (in the variable $INN::Config::version). Other useful variables are also provided (directories, files, programs, masks, parameters) and you should have a look at the source code of the module to see what you can use in your Perl scripts. You only have to declare the module at the beginning of them: use lib '<pathnews>/lib/perl'; use INN::Config; Then, you can for instance use: print $INN::Config::localmaxartsize; to print the value of localmaxartsize as it is set in inn.conf. You can also specify a version when you import the module. If you write: use INN::Config 2.5.0; only versions of INN superior to 2.5.0 will be able to run the Perl script. It is also possible to import the variables directly in your namespace if you specify what you want to import: use INN::Config qw($localmaxartsize $pathbin); Note that a legacy innshellvars.pl is also provided in pathnews/lib for compatibility reasons with old Perl scripts not shipped with INN. It was used by versions of INN anterior to 2.5.0. The corresponding scripts for Shell and Tcl are, however, still in use: innshellvars and innshellvars.tcl. They offer the same capabilities as this module. HISTORY
innshellvars.pl was written by James Brister <brister@vix.com> for InterNetNews in 1996. It was converted to the INN::Config Perl module by Julien Elie in 2007. $Id: Config.pm.in 8357 2009-02-27 17:56:00Z iulius $ SEE ALSO
inn.conf(5), innconfval(1), perl(1). INN 2.5.2 2009-05-21 INN::Config(3pm)
All times are GMT -4. The time now is 07:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy