Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing two cobol source file without sequence numbers

Status
Not open for further replies.

baruch

MIS
Mar 2, 2000
59
IL
HI
How can i use the diff command, to copare two source file
from colume 7.
thx
Barry
 
Hi,

You can't use diff directly, you have some operations to do before to truncate leading sequence numbers.
That is what this sed script is doing.

sed -e 's/^[0-9]*//' prog1.cbl > prog1.cbl.without_seq
sed -e 's/^[0-9]*//' prog2.cbl > prog2.cbl.without_seq

then

diff -bw prog1.cbl.without_seq prog2.cbl.without_seq

After diff, clean the workin files :
rm prog1.cbl.without_seq
rm prog2.cbl.without_seq

Ali

 
Thx Ali
Thats helpfull,

I want to kake in temp area, two other files that contain the seq. numbers, then to attach the orginal seq, to the compareble list.

I wrote a cobol program in dos/pc that do that job.

Any Idea to do that withot cobol program?

Regrds

Barry



 
Hi Ali and thx again.

here a sample that are made in Dos,
At End the seq. numberes reprinted in the fc output.

1. First like you, i made two temp. files without the first seq. dight, (can be duplicate seq. numberes).

2. I made also, index file that its key is the relative number that poinet to the seq. number.

3. Use the Dos command:
Code:
FC /N FC-R.TMP FC-L.TMP >> FC.TMP

4. Restore the oreginal seq.

5. The output is like that.
Code:
COMPARING FILES VCHESHHD.OLD AND VCHESHHD.CBL
VCHESHHD.OLD ******
000026     XOPY VETLIB 201001 THRU 201004.
000027     XOPY NEWLIB 000200 THRU 000204.
VCHESHHD.CBL ******
000026     XOPY VETLIB 201001 THRU 201004.
000027     XOPY VETLIB 203700 THRU 203704.
000027     XOPY NEWLIB 000200 THRU 000204.
******
...

I want to to that task in unix, with sed,perel,awk, etc
with as less as code like cobol.

Regards

Barry
 
Hi Barry,

Try this script, I used semething like this in the past y2k migration to include some waiting modifications that are rising after we take a reference version.



# begin of script
#------------------------------------------------
# control number of arguments
#------------------------------------------------
if [ $# -ne 2 ]
then
print -u2 usage : $0 oldfile newfile
exit 0
fi
OLDFILE=$1
NEWFILE=$2

#------------------------------------------------
# be sure arg1 and arg2 are readable files
#------------------------------------------------
if [ ! -f $OLDFILE ]
then
print -u2 "$OLDFILE not found"
exit 1
fi
if [ ! -f $NEWFILE ]
then
print -u2 "$NEWFILE not found"
exit 1
fi

#--------------------------------------------------------------
# create a file identical to odlfile without sequence numbers
#--------------------------------------------------------------
sed -e 's/^ *[0-9]*//' $OLDFILE >$OLDFILE.wseq

#--------------------------------------------------------------
# create a file identical to newfile without sequence numbers
#--------------------------------------------------------------
sed -e 's/^ *[0-9]*//' $NEWFILE >$NEWFILE.wseq

#--------------------------------------------------------------
# compare the 2 files without sequence numbers and keep differences
# in a file
# the diff is made with the switch -C1 wich prints one line before
# and after the lines that are differentes
#--------------------------------------------------------------
diff -bwC1 $OLDFILE $NEWFILE > $OLDFILE.difwseq
#--------------------------------------------------------------
# founded differences are used as patterns in a file for grep in
# original files, sequence numebers will appear in easy way to read
#--------------------------------------------------------------
grep -f$OLDFILE.difwseq $OLDFILE $NEWFILE | tee $OLDFILE.dif

#--------------------------------------------------------------
# make some cleaning
#--------------------------------------------------------------
rm $NEWFILE.wseq $OLDFILE.difwseq $OLDFILE.wseq

# end of script
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top