Sponsored Content
Top Forums Shell Programming and Scripting Plz Help. Compare 2 files field by field and get the output in another file. Post 302676867 by i150371485 on Wednesday 25th of July 2012 08:09:53 AM
Old 07-25-2012
@Chirel : Thank you so much Smilie Smilie it worked as expected. I have one doubt. if i use for some 50,000 records with 50 columns it is taking more time. is there any way we can reduce the timing and increase the performance ? Plz help ..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AWK to compare two files for each field value

I have "n" files in directory A and "n" files in directory B. The files are expected to be the same with same data. Each file has 14 columns and "x" rows. Of the 14 column, 2 columns are to be considered as key identifiers. Based on this unique combination, I need to compare each field value... (2 Replies)
Discussion started by: Sangtha
2 Replies

2. UNIX and Linux Applications

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 #!/bin/bash myFolder=`pwd` TEMPFILE=$myFolder/tempfile APFILE=$myFolder/file 1.csv... (0 Replies)
Discussion started by: micxshinoda
0 Replies

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

4. Shell Programming and Scripting

Compare two files and output difference, by first field using awk.

It seems like a common task, but I haven't been able to find the solution. vitallog.txt 1310,John,Hancock 13211,Steven,Mills 122,Jane,Doe 138,Thoms,Doe 1500,Micheal,May vitalinfo.txt 12122,Jane,Thomas 122,Janes,Does 123,Paul,Kite **OUTPUT** vitalfiltered.txt 12122,Jane,Thomas... (2 Replies)
Discussion started by: charles33
2 Replies

5. UNIX for Dummies Questions & Answers

compare two files based on common field in unix

I have two files in UNIX. 1st file is Entity and Second File is References. 1st File has only one column named Entity ID and 2nd file has two columns Entity ID | Person ID. I want to produce a output file where entity id's are matching in both the files. Entity File 624197 624252 624264... (4 Replies)
Discussion started by: PRS
4 Replies

6. Shell Programming and Scripting

Compare Field in Current Line with Field in Previous

Hi Guys I have the following file Essentially, I am trying to find the right awk/sed syntax in order to produce the following 3 distinct files from the file above: Basically, I want to print the lines of the file as long as the second field of the current line is equal to the... (9 Replies)
Discussion started by: moutaye
9 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 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

10. UNIX for Dummies Questions & Answers

Combine Similar Output from the 2nd field w.r.t 1st Field

Hi, For example: I have: HostA,XYZ HostB,XYZ HostC,ABC I would like the output to be: HostA,HostB: XYZ HostC:ABC How can I achieve this? So far what I though of is: (1 Reply)
Discussion started by: alvinoo
1 Replies
Stopwatch(3pm)						User Contributed Perl Documentation					    Stopwatch(3pm)

NAME
Time::Stopwatch - Use tied scalars as timers SYNOPSIS
use Time::Stopwatch; tie my $timer, 'Time::Stopwatch'; do_something(); print "Did something in $timer seconds. "; my @times = map { $timer = 0; do_something_else(); $timer; } 1 .. 5; DESCRIPTION
The Time::Stopwatch module provides a convenient interface to timing functions through tied scalars. From the point of view of the user, scalars tied to the module simply increase their value by one every second. Using the module should mostly be obvious from the synopsis. You can provide an initial value for the timers either by assigning to them or by passing the value as a third argument to tie(). If you have the module Time::HiRes installed, the timers created by Time::Stopwatch will automatically count fractional seconds. Do not assume that the values of the timers are always integers. You may test the constant "Time::Stopwatch::HIRES" to find out whether high resolution timing is enabled. A note on timing short intervals Time::Stopwatch is primarily designed for timing moderately long intervals (i.e. several seconds), where the overhead imposed by the tie() interface does not matter. With Time::HiRes installed, it can nonetheless be used for even microsecond timing, provided that appropriate care is taken. o Explicitly initialize the timer by assignment. The first measurement taken before resetting the timer will be a few microseconds longer due to the overhead of the tie() call. o Always subtract the overhead of the timing code. This is true in general even if you're not using Time::Stopwatch. (High-level benchmarking tools like Benchmark.pm do this automatically.) See the code example below. o Take as many measurements as you can to minimize random errors. The Statistics::Descriptive module may be useful for analyzing the data. This advice is also true for all benchmarking. o Remember that a benchmark measures the time take to run the benchmark. Any generalizations to real applications may or may not be valid. If you want real world data, profile the real code in real use. The following sample code should give a relatively reasonable measurement of a the time taken by a short operation: use Time::HiRes; # high resolution timing required use Time::Stopwatch; use Statistics::Descriptive; my $stat = Statistics::Descriptive::Sparse->new(); tie my $time, 'Time::Stopwatch'; # code timer tie my $wait, 'Time::Stopwatch'; # loop timer while ($wait < 60) { # run for one minute my $diff = 0; $time = 0; do_whatever(); $diff += $time; $time = 0; $diff -= $time; $stat->add_data($diff); } print("count: ", $stat->count(), " iterations ", "mean: ", $stat->mean(), " seconds ", "s.d.: ", $stat->standard_deviation(), " seconds "); Note that the above code includes the time of the subroutine call in the measurement. BUGS
Since tied scalars do not (yet?) support atomic modification, use of operators like "$t++" or "$t *= 2" on timers will cause them to lose the time it takes to fetch, modify and store the value. I might be able to get around this by overloading the return value of "FETCH", but I doubt if it's worth the trouble. Just don't do that. There is no way to force low-resolution timing if Time::HiRes has been installed. I'm not sure why anyone would want to, since int() will do just fine if you want whole seconds, but still.. CHANGE LOG
1.00 (15 Mar 2001) Explicitly localized $SIG{__DIE__} when testing for Time::HiRes availability. Added "A note on timing short intervals" to the POD documentation. Bumped version to 1, no longer beta. 0.03 (27 Feb 2001) Modified tests to give more information, reduced subsecond accuracy test to 1/10 seconds to allow for inaccurate select() implementations. Tweaked synopsis and README. SEE ALSO
Time::HiRes, "tie" in perlfunc For a higher-level approach to timing, try (among others) the modules Time::SoFar, Devel::Timer, or Benchmark. Also see the profiling modules Devel::DProf, Devel::SmallProf and Devel::OpProf. AUTHORS
Copyright 2000-2001, Ilmari Karonen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Address bug reports and comments to: perl@itz.pp.sci.fi perl v5.12.3 2001-04-15 Stopwatch(3pm)
All times are GMT -4. The time now is 02:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy