|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have to compare the text file outputs (outputs produced in two
different platforms). Right now, I sed the two files and then compare them. See the script below. #! /bin/csh set sunfile=$1.res set vaxfile=$1.out sed -f fixvaxf.sed $vaxfile >$vaxfile.1 sed -f fixsunf.sed $sunfile >$sunfile.1 diff -bwi $vaxfile.1 $sunfile.1 >$1.diff rm $vaxfile.1 $sunfile.1 This script produces a diff output such as 130c130 < 1 0.0 0.10000E+01 0.67763E-20 0.10000E +01 -0.23962E-05 0.16255E+01 0.16255E+01 --- > 1 0.0 0.10000E+01 0.00000E+00 0.10000E+01 -0.23962E-05 0.16255E+01 0.16255E+01 I would prefer an output of 130c130 < 0.67763E-20 --- > 0.00000E+00 In other words, I want to refine the current diff output to show only the different characters in a diff line output. Is there any way to produce a diff output like the above? I am a newbie to this forum and would welcome any better way of doing the above. Thanks. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Looks like I lost some information while posting (due to automatic
reformatting). Hopefully this message will display correctly. Original output: 274c274 < 1 0.0 0.10000E+01 0.00000E+00 0.10000E+01 --- > 1 0.0 0.10000E+01 -0.34694E-17 0.10000E+01 Preferred output: 274c274 < 0.00000E+00 --- > -0.34694E-17 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Ragu wrote:
> Looks like I lost some information while posting (due to automatic > reformatting). Hopefully this message will display correctly. > > Original output: > 274c274 > < 1 0.0 0.10000E+01 0.00000E+00 0.10000E+01 > --- >> 1 0.0 0.10000E+01 -0.34694E-17 0.10000E+01 > > Preferred output: > 274c274 > < 0.00000E+00 > --- >> -0.34694E-17 The problen is that the real difference would look like this (no "0." and no "E"): 274c274 < 00000 +00 --- > - 34694 -17 -- Best regards | Monica Lewinsky's X-Boyfriend's Cyrus | Wife for President |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
> < 00000 +00
> --- > > - 34694 -17 It is OK. Such an output will me to find the differences quickly. Is there a way to show the outputs like you had mentioned? Thanks. On Mar 24, 10:48am, Cyrus Kriticos <cyrus.kriti...@googlemail.com> wrote: > Ragu wrote: > > Looks like I lost some information while posting (due to automatic > > reformatting). Hopefully this message will display correctly. > > > Original output: > > 274c274 > > < 1 0.0 0.10000E+01 0.00000E+00 0.10000E+01 > > --- > >> 1 0.0 0.10000E+01 -0.34694E-17 0.10000E+01 > > > Preferred output: > > 274c274 > > < 0.00000E+00 > > --- > >> -0.34694E-17 > > The problen is that the real difference would look like this (no "0." and > no "E"): > > 274c274 > < 00000 +00 > --- > > - 34694 -17 > > -- > Best regards | Monica Lewinsky's X-Boyfriend's > Cyrus | Wife for President |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Mon, 24 Mar 2008 07:16:53 -0700, Ragu wrote:
> I have to compare the text file outputs (outputs produced in two > different platforms). Right now, I sed the two files and then compare > them. See the script below. > > #! /bin/csh > set sunfile=$1.res > set vaxfile=$1.out > sed -f fixvaxf.sed $vaxfile >$vaxfile.1 sed -f fixsunf.sed $sunfile > >$sunfile.1 diff -bwi $vaxfile.1 $sunfile.1 >$1.diff rm $vaxfile.1 > $sunfile.1 > > This script produces a diff output such as > > 130c130 > < 1 0.0 0.10000E+01 0.67763E-20 0.10000E +01 > -0.23962E-05 0.16255E+01 0.16255E+01 --- >> 1 0.0 0.10000E+01 0.00000E+00 0.10000E+01 >> -0.23962E-05 0.16255E+01 0.16255E+01 > > I would prefer an output of > > 130c130 > < > 0.67763E-20 > --- >> 0.00000E+00 > > In other words, I want to refine the current diff output to show only > the different characters in a diff line output. Is there any way to > produce a diff output like the above? I am a newbie to this forum and > would welcome any better way of doing the above. Thanks. See if you have "wdiff" installed. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Ragu wrote:
>> < 00000 +00 >> --- >> > - 34694 -17 > > It is OK. Such an output will me to find the differences quickly. > > Is there a way to show the outputs like you had mentioned? Thanks. I don't know. But you can write a script to do what you asked first. e.g. with GNU's bash: --- cut here --- #!/bin/bash FILE1="/somewhere/filename1" FILE2="/somewhere/filename2" while read NO1 LINE1; do read -u 3 NO2 LINE2 if [ "$LINE1" != "$LINE2" ]; then echo line: $NO1 LA1=($LINE1) LA2=($LINE2) for ((I=0; I<=${#LA1[@]}; I++)); do if [ "${LA1[$I]}" = "${LA2[$I]}" ]; then OUT1="${OUT1}\t" OUT2="${OUT2}\t" else OUT1="${OUT1}${LA1[$I]}" OUT2="${OUT2}${LA2[$I]}" fi done echo -e "< $OUT1\n> $OUT2\n---" unset OUT1 OUT2 fi done < <(cat -n "$FILE1") 3< <(cat -n "$FILE2") --- cut here --- Try to avoid commas (,) in both of your files. -- Best regards | Monica Lewinsky's X-Boyfriend's Cyrus | Wife for President |
|
![]() |
| Outils de la discussion | |
|
|