Sponsored Content
Top Forums Shell Programming and Scripting To compare the content of two text files Post 302626347 by birei on Thursday 19th of April 2012 08:31:19 AM
Old 04-19-2012
Hi rammm,

One way using perl:
Code:
$ head sec.txt disp.txt 
==> sec.txt <==
3172

==> disp.txt <==

the file name is
***********
45676
$ cat script.pl
use warnings;
use strict;

my @nums;

while ( <> ) {
        chomp;
        if ( m/\A\d+\Z/ ) {
                push @nums, $_;
                close $ARGV;
        }
}

if ( @nums >= 2 ) {
        printf qq[%s\n], ($nums[0] == $nums[1]) ? q[Equal] : q[Not equal];
}
else {
        printf qq[Error\n];
}
$ perl script.pl sec.txt disp.txt 
Not equal

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compare text files

This may be the 3rd time I'm posting this question. I'm so new here that I'm not even sure how to post! I'm trying to compare two files but can't do a line by line comparison so comm and diff are out. I've been told that I would need to use the awk programing language. I've looked up what I... (14 Replies)
Discussion started by: jimmyflip
14 Replies

2. Shell Programming and Scripting

Compare the content of 2 files

Hi Guys, What is the most effecient way to compare the content of 2 seperate files and extract the result of there is a match? We have 2 separate log files and we are trying to find the common errors from the 2 files. Thanks, Odogbolu98 :( (3 Replies)
Discussion started by: odogbolu98
3 Replies

3. Shell Programming and Scripting

Compare 2 files and output only the different text.

I know the diff does this but it does output more info than just the different text (e.g. $ diff file1 file2 29a30 > /home/alex/Pictures/hello.jpg 1694a1696 > /home/alex/Pictures/hi.jpg ) How can I make it output only /home/alex/Pictures/hello.jpg /home/alex/Pictures/hi.jpg ? thank... (2 Replies)
Discussion started by: hakermania
2 Replies

4. Shell Programming and Scripting

How to compare two text files

Hi Team, Could you please help me on below one .. etrademail1.txt etDefaultLogin=pdayanan mail=poojaaragam.dayanand@exchange.etr.comx employeeNumber=31567 etDefaultLogin=sudrupa mail=sudrupa.ayanand@exchange.etr.comx employeeNumber=318967 etDefaultLogin=gurathi (1 Reply)
Discussion started by: nivas_k2006
1 Replies

5. Shell Programming and Scripting

compare 2 files and show count same content.

$ cat File1 Non HTTP response code:java.net.ConnectException225073X 000000005143329Load time: 402335410224 Non HTTP response code: ava.net.ConnectException206423X 000000005143330Load time: 402305687161 Non HTTP response code: ava.net.ConnectException290212X 000000005143331Load time:... (1 Reply)
Discussion started by: ooilinlove
1 Replies

6. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

7. UNIX for Dummies Questions & Answers

Compare two text files

Hello guys, I have file1 and file2, two text files containing various lines. I'm trying to find a way to compare file1 and file2: If the first 7 characters of a line in file2 match the first 7 characters of a line in file1, then do not do anything. Print out the lines of file1 (in file3,... (3 Replies)
Discussion started by: bobylapointe
3 Replies

8. Shell Programming and Scripting

Script to compare two text files

i am working on a shell script and need help in the comparing part of it. for e.g. there two text files like this: file1.txt name1 name2 name3 file1 has to be comared with file2 defaultfile.txt name1 name2 name3 name4 and during comparision with defaultfile.txt if... (2 Replies)
Discussion started by: draghun9
2 Replies

9. Shell Programming and Scripting

Compare two fields in text files?

Hi, I have two text files, compare column one in both the files and if it matches then the output should contain the id in column one, the number and the description. Both the files are sorted. Is there a one liner to get this done, kindly help. Thank you File 1: NC_000964 92.33 ... (2 Replies)
Discussion started by: pulikoti
2 Replies

10. Shell Programming and Scripting

Compare content between two files

I have two files in unix environment with similer type of contain: Example: File1 File2 Milestone1 Milestone1 Milestone2 Milestone12 Milestone3 Milestone13... (11 Replies)
Discussion started by: Mrinal Mondal
11 Replies
MPI_Type_hvector(3OpenMPI)												MPI_Type_hvector(3OpenMPI)

NAME
MPI_Type_hvector - Creates a vector (strided) datatype with offset in bytes -- use of this routine is deprecated. SYNTAX
C Syntax #include <mpi.h> int MPI_Type_hvector(int count, int blocklength, MPI_Aint stride, MPI_Datatype oldtype, MPI_Datatype *newtype) Fortran Syntax INCLUDE 'mpif.h' MPI_TYPE_HVECTOR(COUNT, BLOCKLENGTH, STRIDE, OLDTYPE, NEWTYPE, IERROR) INTEGER COUNT, BLOCKLENGTH, STRIDE, OLDTYPE INTEGER NEWTYPE, IERROR INPUT PARAMETERS
count Number of blocks (nonnegative integer). blocklength Number of elements in each block (nonnegative integer). stride Number of bytes between start of each block (integer). oldtype Old datatype (handle). OUTPUT PARAMETERS
newtype New datatype (handle). IERROR Fortran only: Error status (integer). DESCRIPTION
Note that use of this routine is deprecated as of MPI-2. Use MPI_Type_create_hvector instead. This deprecated routine is not available in C++. The function MPI_Type_hvector is identical to MPI_Type_vector, except that stride is given in bytes, rather than in elements. The use for both types of vector constructors is illustrated in the examples in Section 3.12.7 of the MPI-1 Standard. Assume that oldtype has type map {(type(0), disp(0)), ..., (type(n-1), disp(n-1))} with extent ex. Let bl be the blocklength. The newly created datatype has a type map with count * bl * n entries: {(type(0), disp(0)), ..., (type(n-1), disp(n-1)), (type(0), disp(0) + ex), ..., (type(n-1), disp(n-1) + ex), ..., (type(0), disp(0) + (bl -1) * ex),...,(type(n-1), disp(n-1) + (bl -1) * ex), (type(0), disp(0) + stride), ...,(type(n-1), disp(n-1) + stride), ..., (type(0), disp(0) + stride + (bl - 1) * ex), ..., (type(n-1), disp(n-1) + stride + (bl -1) * ex), ..., (type(0), disp(0) + stride * (count -1)), ...,(type(n-1), disp(n-1) + stride * (count -1)), ..., (type(0), disp(0) + stride * (count -1) + (bl -1) * ex), ..., (type(n-1), disp(n-1) + stride * (count -1) + (bl -1) * ex)} ERRORS
Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument. C++ func- tions do not return errors. If the default error handler is set to MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism will be used to throw an MPI:Exception object. Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error. SEE ALSO
MPI_Type_create_hvector MPI_Type_vector Open MPI 1.2 September 2006 MPI_Type_hvector(3OpenMPI)
All times are GMT -4. The time now is 09:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy