Afficher un message
Vieux 24/03/2008, 20h07   #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
 
Page generated in 0,04769 seconds with 9 queries