Computing.Net > Forums > Unix > Find un-match in two files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Find un-match in two files

Reply to Message Icon

Name: jacky599
Date: April 9, 2008 at 20:22:25 Pacific
OS: Solaris
CPU/Ram: SUN
Product: SUN
Comment:

Perl Expert please assist:

This not a hw assignment, this a research work.
I have started it have some code in place, I need your help.

Need to compare two diffrent files:
file1.xyz resides in a local server
file2.pqr resides in a remote server

The script will look for un-match of string next field "name"(file1.xyz first entry of name is "newton" pleas see below example of the data) in both files and only will send out email if there is an un-match and/or duplicates are found.

So here what I have written so far:


# Build an array of the Servers.

@Servers = (
'server1',
'server2',
'server3',
'server4',
'server5',
'server6',
);

#Location of file2 and then I am copying file2 to diff directory for comparison
#location of file2 in remote server.

$file2 = "/os/bbs/file2.pqr"

#copy file2 to this location

$Copy_file2 = "/tmp/Comparelog"


# In a foreach loop copy every single file2 files from all remote servers

forearch $RemoteServer(@Servers)
{

#Get all file2 files from the Remote Servers

#This command will work directly and will not require passwd. this command scp to every remote servers and will copy all file2 files to "/tmp/Comparelog" directory with servernme

system ("scp -P 1111 $RemoteServer:$Copy_file2. $RemoteServer");

}


NOW I NEED TO FIND OUT OPEN EVERY SINGLE FILE2 TO FROM EACH SERVER from above loo that copies AND THEN COMPARE WITH EACH LOCAL SERVER ("/COMP/CFILE.PPT/file1.xyz)

file2.pqr >>>>>>>>>>>>> compare with local server (server 1) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 2) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 3) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 4) file1.xyz
file2.pqr >>>>>>>>>>>>> compare with local server (server 5) file1.xyz


should I also copy all local file1.xyz to "tmp/Comparelog" directory or I can compare on the fly
here ("/COMP/CFILE.PPT/file1.xyz)


The e-mail should output as follow:

Listed below are sites that need to be looked at for NOT existing in files on BOTH Local and the Remote servers:

File on Server1 :
(/abc/def/file1.xyz)

File on Remote Server: (/os/bbs/file2.pqr)

(Print the above only ONCE! top of the e-mail header)

***********************************UNMATCH FOUND**********************

Local(Server1) Remote(Server2)

None einsterin

Local(Server1) Remote(Server2)

watts None

*************************DUPLICATES FOUND**********************


Local(Server1) Remote(Server2)

James None

None cook

lavoyse lavoyse

file1.xyz format: (located in local server)

turning on
name newton
point direct
terminal 2
protocol TCP
port 197


turning on
name darwin
point direct
terminal 2
protocol TCP
port 197

turning on
name curie
point direct
terminal 2
protocol TCP
port 197


turning on
name farad
point direct
terminal 2
protocol TCP
port 197


turning on
name watts
point direct
terminal 2
protocol TCP
port 197

turning on
name james
point direct
terminal 2
protocol TCP
port 197

turning on
name james
point direct
terminal 2
protocol TCP
port 197


turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197

turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197

Following is file2.pqr (Remote server forexample Remote server - remote server 2

turning on
name newton
point direct
terminal 2
protocol TCP
port 197


turning on
name darwin
point direct
terminal 2
protocol TCP
port 197

turning on
name curie
point direct
terminal 2
protocol TCP
port 197


turning on
name farad
point direct
terminal 2
protocol TCP
port 197

turning on
name einsterin
point direct
terminal 2
protocol TCP
port 197

turning on
name cook
point direct
terminal 2
protocol TCP
port 197


turning on
name cook
point direct
terminal 2
protocol TCP
port 197

turning on
name lavoyse
point direct
terminal 2
protocol TCP
port 197



Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Find un-match in two files

Find match in two diff files at tim www.computing.net/answers/unix/find-match-in-two-diff-files-at-tim/8061.html

Find duplicate words in a file www.computing.net/answers/unix/find-duplicate-words-in-a-file/7999.html

find unwanted characters in file www.computing.net/answers/unix/find-unwanted-characters-in-file/7046.html