![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Very urgent :- How to compare string using if statement | jisha | Shell Programming and Scripting | 1 | 01-14-2008 03:41 AM |
| Urgent Help: Perl Hash compare | jamie123 | Shell Programming and Scripting | 10 | 01-04-2008 03:09 AM |
| Compare Data in the same file | lweegp | UNIX for Dummies Questions & Answers | 1 | 10-17-2005 03:32 AM |
| Compare data files | ithomp | Shell Programming and Scripting | 1 | 06-15-2004 11:08 AM |
| compare data | bensky | UNIX for Dummies Questions & Answers | 3 | 10-10-2003 06:17 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hi all,
very need help urgently ![]() 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 |
|
||||
|
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
|
|
||||
|
hi anbu,
thank you so much for your attention Quote:
Last edited by bucci; 02-28-2007 at 12:27 AM.. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|