PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Diff showing only the different characters
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Diff showing only the different characters

Réponse
 
LinkBack Outils de la discussion
Vieux 24/03/2008, 15h16   #1
Ragu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Diff showing only the different characters

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.
  Réponse avec citation
Vieux 24/03/2008, 15h37   #2
Ragu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Diff showing only the different characters

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

  Réponse avec citation
Vieux 24/03/2008, 15h48   #3
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Diff showing only the different characters

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
  Réponse avec citation
Vieux 24/03/2008, 16h49   #4
Ragu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Diff showing only the different characters

> < 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


  Réponse avec citation
Vieux 24/03/2008, 18h17   #5
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Diff showing only the different characters

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.
  Réponse avec citation
Vieux 24/03/2008, 19h07   #6
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Diff showing only the different characters

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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 14h09.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,14901 seconds with 14 queries