Plz explain the process of this code....

Hi Unix Gurus,

Please explain the processing done by the code mentioned below:

for (i=1;i<=59;i++)
	{
	    sub(/  *$/,"", $i)
	}
	newrec_key = $2
	new_line = $0
	if (empty_oldfile==1)
	{
		#newly added record
		++num_add
		print "Added key: ", newrec_key > LogFile

		#print out the newly added record
		print new_line > OutputFile

	}

Thanks

Is that awk? Telling us what language you have would help us help you. Assuming awk or something close, the code in blue looks like it is taking each of the first 59 fields in the record and dropping any trailling spaces.

yes...it is awk.....

for (i=1;i<=59;i++)     #loop through 59 fields in each line of the input
	{
	    sub(/  *$/,"", $i)      #remove all spaces in each field
	}
	newrec_key = $2
	new_line = $0
	if (empty_oldfile==1)    #this variable might be somewhere in the code you didn't paste here
	{
		#newly added record
		++num_add
		print "Added key: ", newrec_key > LogFile   #output the 2nd field to "LogFile"

		#print out the newly added record
		print new_line > OutputFile          #copy the whole line to "OutputFile"

	}

hey thanx......
its has helped me in understanding the correct logic here....
thanks a lot!!!!