[urgent need help]compare data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [urgent need help]compare data
# 1  
Old 02-27-2007
Error [urgent need help]compare data

hi all,

very need help urgently Smilie

i have a problem compare 2 files from solaris, the 2 files its shown below:

data1.log :
6512345678 6512345677 20070131 073824 420
6511111111 6522222222 20070131 103747 87
6522222222 6233333333 20070131 120855 31
6533333333 6244444444 20070131 121006 48


data2.log:
P 055006.410 20070131 073824 6511111111 510000000000000 6511111111 00 0 000 012 0 0 0
P 055006.530 20070131 103747 6522222222 510000000000000 6522222222 00 0 000 003 0 0 0
P 055006.531 20070131 120855 6533333333 510000000000000 6533333333 00 0 000 004 0 0 0
P 055006.590 20070131 121006 11111111111 510000000000000 11111111111 00 0 000 003 0 0 0
P 055006.650 20070131 133333 222222222 510000000000000 22222222222 00 0 000 003 0 0 0

compare from data1.log to data2.log on column 1, column 3 and column 4 for data1.log compare with column 3, column 4 and column 7 for data2.log
if match and write it to files.

expected output is:

success :
6511111111 6522222222 20070131 103747 87
P 055006.410 20070131 073824 6511111111 510000000000000 6511111111 00 0 000 012 0 0 0


6522222222 6233333333 20070131 120855 31
P 055006.530 20070131 103747 6522222222 510000000000000 6522222222 00 0 000 003 0 0 0


6533333333 6244444444 20070131 121006 48
P 055006.531 20070131 120855 6533333333 510000000000000 6533333333 00 0 000 004 0 0 0


fail :
6512345678 6512345677 20070131 073824 420


fail output if data on data1.log not found in data2.log

please need advices with script or using syntax command


thank you so much

regards,

bucci
# 2  
Old 02-27-2007
I find column 1, column 3 of data1 match with col 7 and col 3 of data2.
Code:
awk ' BEGIN { while( getline < "data1.log" ) { str[$1" "$3]=$0 } }
{ 
if ( str[$7" "$3] !~ /^ *$/ ) 
{ 
	print str[$7" "$3] "\n" $0 "\n\n" > "success"
	delete str[$7" "$3];
}
} 
END { 
for( key in str) {
if ( str[key] !~ /^ *$/ ) 
	print str[key] >"fail"
} }
' data2.log

# 3  
Old 02-27-2007
hi anbu,

thank you so much for your attention



Quote:
Originally Posted by anbu23
I find column 1, column 3 of data1 match with col 7 and col 3 of data2.
Code:
awk ' BEGIN { while( getline < "data1.log" ) { str[$1" "$3]=$0 } }
{ 
if ( str[$7" "$3] !~ /^ *$/ ) 
{ 
	print str[$7" "$3] "\n" $0 "\n\n" > "success"
	delete str[$7" "$3];
}
} 
END { 
for( key in str) {
if ( str[key] !~ /^ *$/ ) 
	print str[key] >"fail"
} }
' data2.log


Last edited by bucci; 02-28-2007 at 12:27 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Compare data - Match first column and compare second

Hi guys, looking for some help with a way to compare data in two files but with some conditions. example, File 1 consists of site1,10.1.1.1 site2,20.2.2.2 site3,30.3.3.3 File 2 contains site1,l0.1.1.1 site2,50.1.1.1 site3,30.3.3.3 site4,40.1.1.1 I want to be able to match the... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. Shell Programming and Scripting

Need Urgent Help from UNIX gurus to get specific data from a file

Hi, I have a file monitor.txt as below... # Times are converted to local time from GMT. # Local Timezone: EST (GMT -05:00) PARAM1 { TIME 30; CC1 "xxxxx"; CC2 "xxxxx"; CC3 "xxxxx"; CC4 "xxxxx"; } PARAM2 { 4061 :... (3 Replies)
Discussion started by: zaq1xsw2
3 Replies

3. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

4. Shell Programming and Scripting

Compare two file (please help me it's deadly urgent)

I have many files with info about soft, installed on remote machines. I need to compare this file with template (soft than must be installed) and output file must content info about software that's not installed. template.txt software_name1 software_name2 software_name3.1 ... (14 Replies)
Discussion started by: cintlt
14 Replies

5. Shell Programming and Scripting

open 2 files and compare values script - urgent

Hi gurus I have two csv files that are outputs. The file contains data similar to s.no,number1,number2,date1 -------------------------------- 1, a123,482.29,11/28/07 13:00 2,a124,602.7,9/24/07 14:00 3,a125,266.93,10/9/07 16.48 4,a126,785.15,11/14/07 16:08 <file 2> s.no name... (2 Replies)
Discussion started by: inkyponky
2 Replies

6. Shell Programming and Scripting

urgent<parsing data from a excel file>

Hi all, I wud like to get ur assistance in retrieving lines containing l1.My excel dataset contains around 8000 lines.I converted it into a text tab delimiter file and got the lines containing l1,My output is a list of lines containing l1 saved in a outfile.Some of d lines from my outfile s... (5 Replies)
Discussion started by: sayee
5 Replies

7. Shell Programming and Scripting

URGENT:- Data Scrubbing

Hi All, I have a Flatfile (any delimitation) of millions of lines of data, where in i have to scrubb the data of the line from the position ($1 ) given in input parameter until the length ($2) given in the input parameter. I utilised awk , sed but i am unable to do it. scrub key - 12345... (7 Replies)
Discussion started by: padhu.47
7 Replies

8. Shell Programming and Scripting

urgent help : want to check data in oracle from flate file

Hi All, I have a flat file like this on unix AIX server: MXBOFO CSWP 5340 3794499 MXBOBIS CSWP 5340 3581124 MXBOFO CSWP 5340 3794531 MXBOBIS CSWP 5340 3583720 MXBOFO CSWP 5340 3794514 MXBOBIS CSWP 5340 3580763 MXBOFO CSWP 5340 3795578 MXBOBIS CSWP 5340 3794995 MXBOFO CSWP 5340 3710835... (3 Replies)
Discussion started by: unknown123
3 Replies

9. Shell Programming and Scripting

Get data from 3 differrnt oracle DB & then compare data

Hi All, I have a requirement to write a shell script for the following... we have 3 different database.... lets say A, B, C From these 3 DBs, i need to get data.. all have 3 different table...a,b, c A.a => Emp_code, count(*) B.b => emp_code, count(*) C.c => emp_code, copunt(*) Once get this... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

10. Shell Programming and Scripting

Very urgent :- How to compare string using if statement

Hi How can i compare a string using if statement in a script? For eg: I have filename="abc.sh" if ;then { ....... ....... } fi but this doesnot work .. How will i execute this ?? Thanks in advance (1 Reply)
Discussion started by: jisha
1 Replies
Login or Register to Ask a Question