Sponsored Content
Full Discussion: compare 2 arrays in perl
Top Forums Shell Programming and Scripting compare 2 arrays in perl Post 302341387 by durden_tyler on Wednesday 5th of August 2009 07:56:46 PM
Old 08-05-2009
Quote:
Originally Posted by karla
one more thing: how can i access the value in 5th column and compare it to the corresponding line, printing the difference, or, warning that this line exists only in one file
(1) For two similar lines of data, is the 5th column the only one that can be different ?

(2) What exactly is that difference ?

(a) KB0005_value minus KB204320_value, or
(b) KB204320_value minus KB0005_value, or
(c) absolute difference ?

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare two arrays in sh or compare two fields

I want a soultion to compare two arrays in sh with an easy way.I want a solution to synchrose users between different AIX servers where no NIS is available. All users are meant to be same on all 10 servers. So the approach is to consider first server as master user repository and whatever the users... (0 Replies)
Discussion started by: rijeshpp
0 Replies

2. Shell Programming and Scripting

Perl - Compare 2 Arrays

Hi all, I have the following script where the contents of file1 and file2 would be something like this: file1: 56790,0,0,100998765 89756,0,0,100567876 867645,1,3,678777654 file2: 56790,0,0,100998765 65776,0,0,4766457890 +5896,0,0,675489876 What I then want to do is check if... (4 Replies)
Discussion started by: Donkey25
4 Replies

3. Shell Programming and Scripting

compare/match arrays

Hi there all, I am having a question. Is it posible to compare elements of 2 different arrays? For example I got Array 1 | Array 2 123_abc | 123_bcd 123_bcd | 234_bcd 234_abc | 567_abc 234_bcd | 123_abc than the match is 123_abc & 234_bcd and non of the others. So... (3 Replies)
Discussion started by: draco
3 Replies

4. Shell Programming and Scripting

Compare arrays in perl

Hello, Let's say that we have the two following arrays @array1= @array2= Is there any easy way to compare these two arrays and print the values that exist in array1 and not in array2 and the values that exist in array2 and not in array1? Regards, Chriss_58 (3 Replies)
Discussion started by: chriss_58
3 Replies

5. Shell Programming and Scripting

Compare arrays (perl)

Hi, my first post here! Description of my problem: I have one txt-file with six rows and each row contains seven numbers seperated with whitespaces. I want to: Compare one array with seven numbers with each row of numbers in the txt-file. I have managed to compare one array with... (6 Replies)
Discussion started by: mjoh
6 Replies

6. Shell Programming and Scripting

Perl Compare 2 Arrays

Hello, Consider the following 2 arrays: Array1 = qw(Fa0/0 Fa0/1 Fa0/2 Fa0/3); Array1 = qw(Fa0/1 Fa0/2 Fa0/3 Fa0/4); I want to compare the following 2 arrays as follows: Take specific action when elements of Array1 that doesn't exist in Array2 (in my example: Fa0/0). Take another... (4 Replies)
Discussion started by: ahmed_zaher
4 Replies

7. Shell Programming and Scripting

perl: compare two arrays

Hi friends, I want to compare two arrays and find matched one using perl? Also, I want to delete unmatched one. Plz suggest me solution (1 Reply)
Discussion started by: Renesh
1 Replies

8. Shell Programming and Scripting

Compare two arrays

Hi, I am trying to compare two lists that are held in two variables so I believe I need to access the array elements to compare these. I am using ksh 88 and the code I have tried is below: for file in ${origfilelist} do if ]] then print -- "File ${file}... (3 Replies)
Discussion started by: frodo61
3 Replies

9. Shell Programming and Scripting

Using Diff to compare 2 arrays

I have two arrays and they look like this: array=(`cat /local/mnt/*sys/*includes|grep -v NEW`) array2=(`cat /tmp/*sys.z |grep -v NEW`) I am trying to compare them but I need to use the diff -u command. I am not sure how to do this. I cannot just do diff -u ${array} ${array2} I cannot... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. UNIX for Beginners Questions & Answers

Compare bash arrays issue

Hello everyone, I need help comparing 2 arrays. the first array is static; the second array is not .. array1=( "macOS Mojave" "iTunes" ) cd /Volumes array2=( * ) # output of array2 macOS Mojave iTunes Mac me The problem occurs when I compare the arrays with the following code - ... (6 Replies)
Discussion started by: trexthurman
6 Replies
NUMDIFF(1)							   User Commands							NUMDIFF(1)

NAME
numdiff - compare similar files with numeric fields DESCRIPTION
Usage: numdiff -h|--help|-v|--version or numdiff [-s IFS][-a THRVAL[:RANGE|:RANGE1:RANGE2]][-r THRVAL[:RANGE|:RANGE1:RANGE2]][-2][-F NUM][-# NUM][-P][-N][-I][-c CURRNAME][-d C1C2][-t C1C2][-g N1N2][-p C1C2][-n C1C2][-e C1C2][-i C1C2][-X 1:RANGE][-X 2:RANGE][-E][-D][-b][-V][-O[NUM]][-q][-S][-z 1:RANGE][-z 2:RANGE][-Z 1:RANGE][-Z 2:RANGE][-m][-H][-f[NUM]][-T][-B][-l PATH][-o PATH] FILE1 FILE2 Compare putatively similar files line by line and field by field, ignoring small numeric differences or/and different numeric formats. RANGE, RANGE1 and RANGE2 stay for a positive integer value or for a range of integer values, like 1-, 3-5 or -7. The two arguments after the options are the names of the files to compare. The complete paths of the files should be given, a directory name is not accepted. The given paths cannot refer to the same file but one of them can be "-", which refers to stdin. Exit status: 1 if files differ, 0 if they are equal, -1 (255) in case of error -s, --separator=IFS Specify the set of characters to use to split the input lines into fields (The default set of characters is space, tab and newline). If IFS is prefixed with 1: or 2: then use the given character set only for the lines from the first or the second file respectively -a, --absolute-tolerance=THRVAL[:RANGE|:RANGE1:RANGE2] Set to THRVAL the maximum absolute difference permitted before that two numeric fields are regarded as different (The default value is zero). If a RANGE is given, use the specified threshold only when comparing fields whose positions lie in RANGE. If both RANGE1 and RANGE2 are given and have the same length, then use the specified threshold when comparing a field of FILE1 lying in RANGE1 with the corresponding field of FILE2 in RANGE2 -r, --relative-tolerance=THRVAL[:RANGE|:RANGE1:RANGE2] Set to THRVAL the maximum relative difference permitted before that two numeric fields are regarded as different (The default value is zero). If a RANGE is given, use the specified threshold only when comparing fields whose positions lie in RANGE. If both RANGE1 and RANGE2 are given and have the same length, then use the specified threshold when comparing a field of FILE1 lying in RANGE1 with the corresponding field of FILE2 in RANGE2 -2, --strict Consider two numerical values as equal only if both absolute and relative difference do not exceed the corresponding tolerance threshold -F, --formula=NUM Use the formula indicated by NUM to compute the relative errors. If 'NUM' is 0 use the classic formula. If 'NUM' is 1 compute the relative errors by considering the values in FILE1 as sample values. If 'NUM' is 2 compute the relative errors by considering the values in FILE2 as sample values. -#, --digits=NUM Set to NUM the number of digits in the significands used in multiple precision arithmetic -P, --positive-differences Ignore all differences due to numeric fields of the second file that are less than the corresponding numeric fields in the first file -N, --negative-differences Ignore all differences due to numeric fields of the second file that are greater than the corresponding numeric fields in the first file -I, --ignore-case Ignore changes in case while doing literal comparisons -c, --currency=CURRNAME Set to CURRNAME the currency name for the two files to compare. CURRNAME must be prefixed with 1: or 2: to specify the currency name only for the first or the second file -d, --decimal-point=C1C2 Specify the characters representing the decimal point in the two files to compare -t, --thousands-separator=C1C2 Specify the characters representing the thousands separator in the two files to compare -g, --group-length=N1N2 Specify the number of digits forming each group of thousands in the two files to compare -p, --plus-prefix=C1C2 Specify the (optional) prefixes for positive values used in the two files to compare -n, --minus-prefix=C1C2 Specify the prefixes for negative values used in the two files to compare -e, --exponent-letter=C1C2 Specify the exponent letters used in the two files to compare -i, --imaginary-unit=C1C2 Specify the characters representing the imaginary unit in the two files to compare -X, --exclude=1:RANGE Select the fields of the first file that have to be ignored -X, --exclude=2:RANGE Select the fields of the second file that have to be ignored -E, --essential While printing the differences between the two compared files show only the numerical ones -D, --dummy While printing the differences between the two compared files neglect all the numerical ones (dummy mode) -b, --brief Suppress all messages concerning the differences discovered in the structures of the two files -V, --verbose For every couple of lines which differ in at least one field print an header to show how these lines appear in the two compared files -O, --overview[=NUM] Display a side by side difference listing of the two files showing which lines are present only in one file, which lines are present in both files but with one or more differing fields, and which lines are identical. If 'NUM' is zero or is not specified, output at most 130 columns per line. If 'NUM' is a positive number, output at most 'NUM' columns per line. If 'NUM' is a negative number, do not output common lines and display at most -'NUM' columns per line. -q, --quiet, --silent Suppress all the standard output -S, --statistics Add some statistics to the standard output -z, --blur-if-numerical=1:RANGE Select the fields of the first file that have to be blurred during the synchronization procedure only if they turn out to be numeric -z, --blur-if-numerical=2:RANGE Select the fields of the second file that have to be blurred during the synchronization procedure only if they turn out to be numeric -Z, --blur-unconditionally=1:RANGE Select the fields of the first file that have to be unconditionally blurred during the synchronization procedure -Z, --blur-unconditionally=2:RANGE Select the fields of the second file that have to be unconditionally blurred during the synchronization procedure -m, --minimal During synchronization try hard to find a smaller set of changes -H, --speed-large-files During synchronization assume large files and many scattered small changes -f, --test-filter[=NUM] Run only the filter and then show the results of its attempt to synchronize the two files. If 'NUM' is zero or is not specified, output at most 130 columns per line. If 'NUM' is a positive number, output at most 'NUM' columns per line. If 'NUM' is a negative number, do not output common lines and display at most -'NUM' columns per line. -T, --expand-tabs Expand tabs to spaces in output while displaying the results of the synchronization procedure (meaningful only together with option -O or -f) -B, --binary Treat both files as binary files (only meaningful under Doz/Windoz) -l, --warnings-to=PATH Redirect warning and error messages from stderr to the indicated file -o, --output=PATH Redirect output from stdout to the indicated file -h, --help Show help message and predefined settings -v, --version Show version number, Copyright, Distribution Terms and NO-Warranty Default numeric format (for both files to compare): Currency name = "" Decimal point = `.' Thousands separator = `,' Number of digits in each thousands group = 3 Leading positive sign = `+' Leading negative sign = `-' Prefix for decimal exponent = `e' Symbol used to denote the imaginary unit = `i' COPYRIGHT
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Ivano Primi <ivprimi@libero.it> License GPLv3+: GNU GPL version 3 or later, see <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for numdiff is maintained as a Texinfo manual. If the info and numdiff programs are properly installed at your site, the command info numdiff should give you access to the complete manual. numdiff 5.6.0 January 2012 NUMDIFF(1)
All times are GMT -4. The time now is 11:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy