- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: file comparing
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 02:49 AM
03-22-2004 02:49 AM
file comparing
I need a way to compare two files and see the differences side by side not useing "sdiff"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 02:52 AM
03-22-2004 02:52 AM
Re: file comparing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 03:00 AM
03-22-2004 03:00 AM
Re: file comparing
group|New|Old
sdiff only compare lines side by side. if i add a line to one of the files that will move the lines compared to the other file i will get that the line do not match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 03:55 AM
03-22-2004 03:55 AM
Re: file comparing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 06:37 AM
03-22-2004 06:37 AM
Re: file comparing
I think I can sympathize with the basic request, but a
little more information is needed to help define an answer.
Let me answer through a counter-example.
I while ago felt the need to compare two SAP 'R3.out' files
from rather different SAP systems. So there were going to be a bunch
of known differences. Too much for standard tools to be useful.
So my script started out by recognizing the key difference:
'SAP system name' and 'Instance name'. In the partial data sample
below those were 'XXX' and 'Dnn'. Data value with this strings
were all replaced by a generic {SID} and {INST} strings before comparing.
There were also missing lines to deal will, similar to the 'resync' that
sdiff does as mentioned in an earlier reply.
I did have one powerful bit of knowledge... the params were sorted by name.
So I could read left, read right in general but read more rights if
left became too high or read more lefts if the right seemed to escape
I also wanted the report as name/left/right
much similar to the group/old/new requested.
Here is some sample input (modfied to protect the innocent :-):
rslg/send_daemon/autostart 0
rslg/send_daemon/exe_file /usr/sap/XXX/SYS/exe/run/rslgsend
rslg/send_daemon/listen_port (!) 3700
rslg/send_daemon/pid_file /usr/sap/XXX/Dnn/data/rslgspid
rslg/send_daemon/status_file /usr/sap/XXX/Dnn/data/rslgssta
rslg/send_daemon/talk_port (!) 1300
Here is some sample output from my script:
Parameter XXX - Dnn YYY - D02
------------------------------ ? -------------------- ? --------------------
DIR_CLIENT_ORAHOME | /oracle/{SID} X /oracle/{SID}/901_64
DIR_ORAHOME | /oracle/{SID} X /oracle/{SID}/901_64
DIR_SERVER_ORAHOME | /oracle/{SID} X /oracle/{SID}/901_64
ES/SHM_MAX_PRIV_SEGS X 63 | 2
ES/SHM_PROC_SEG_COUNT X 64 | 3
ES/TABLE X SHM_SEGS | UNIX_STD
:
rslg/send_daemon/listen_port X 3700 X 3702
rslg/send_daemon/talk_port X 1300 X 1302
So the lines with 'port' got picked up, but the lines with 'pid_file' were
not because they were logically equal
And below is the script. Maybe it is enough to get you going.
Perhpas enough even to solve your problem (unlikely),
but hopefully at least enough to make you ask the right question!
Enjoy,
Hein.
#!/bin/perl
# }
$f1 = @ARGV[0];
$f2 = @ARGV[1];
$ALL = @ARGV[2];SAP System\s+(\w+)\s/);
die "Must provide two R3.out files to compare" unless $f2;
open (F1, $f1) || die "Error open file 1: $f1";
open (F2, $f2) || die "Error open file 2: $f2";
# Find system ID and first parameter
# (also pick up SAPLOCALHOST? )
while (
$S1 = $1 if (/SAP System\s+(\w+)\s/);
$I1 = $1 if (/^INSTANCE_NAME\s+\(!\) (\w+)/);
last if (/^Param/);
}
while (
$S2 = $1 if (/SAP System\s+(\w+)\s/);
$I2 = $1 if (/^INSTANCE_NAME\s+\(!\) (\w+)/);
last if (/^Param/);
}
$format = "%-30.30s %s %-20s %s %-20s\n";
print "\nColumn \"?\" legend: \"|\" = default, \"X\" = changed, \" \" = missing.\n\n";
printf $format, "Parameter", " ", "$S1 - $I1", " ", "$S2 - $I2";
printf $format, "------------------------------","?","--------------------",
"?","--------------------";
while (
$v1 = " ";
if (/^(\S+).*( |\(!\)) (.{1,20})/) {
$k1 = $1;
$d1 = ($2 eq " ") ? "|" : "X";
$v1 = $3;
$v1 =~ s/$S1/{SID}/g;
$v1 =~ s/$I1/{INST}/g;
}
while ($k2 lt $k1) {
last unless ($_ =
$v2 = " ";
if (/^(\S+).*( |\(!\)) (.{1,20})/) {
$k2 = $1;
$d2 = ($2 eq " ") ? "|" : "X";
$v2 = $3;
$v2 =~ s/$S2/{SID}/g;
$v2 =~ s/$I2/{INST}/g;
}
if ($k2 lt $k1) {
printf $format, $k2, " ", " ", $d2, $v2;
}
}
if ($k1 eq $k2) {
printf $format, $k1, $d1, $v1, $d2, $v2 if
# ($ALL eq "all" || ($v1 ne $v2 && (($d1.$d2 ne "||")||($ALL eq "more")));
# ($ALL || ($v1 ne $v2 && ($d1.$d2 ne "||") ) );
($ALL || ($v1 ne $v2) );
} else {
printf $format, $k1, $d1, $v1, " ", " ";
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2004 07:11 AM
03-22-2004 07:11 AM
Re: file comparing
$man comm
DESCRIPTION
comm reads file1 and file2, which should be ordered in increasing collating sequence (see sort(1) and Environment Variables below), and produces a three-column output:
Column 1: Lines that appear only in file1,
Column 2: Lines that appear only in file2,
Column 3: Lines that appear in both files.
If - is used for file1 or file2, the standard input is used.
Options 1, 2, or 3 suppress printing of the corresponding column. Thus comm -12 prints only the lines common to the two files; comm -23 prints only lines in the first file but not in the second; comm -123 does nothing useful.