@echo off

rem clean up mined position marker file @mined.mar

rem DOS versions of following Unix programs are required:
rem	egrep, sed, sort, uniq
rem adapt unixpath as needed:
set unixpath=C:\bin\unix;C:\cygwin\bin;D:\bin\unix;D:\cygwin\bin

set PATH=%unixpath%;%PATH%

egrep -n "" @mined.mar | sed -e "s,:, ," > @mined.$$1
sort -r +1 -2 +0rn -1 @mined.$$1 > @mined.$$2
sed -e "s,^[^ ]* ,," -e "s,^\([^ ]*\) \(.*\)$,\2	\1," -e "s, ,,g" @mined.$$2 > @mined.$$5
uniq -f 1 @mined.$$5 > @mined.$$6
sed -e "s,^\(.*\)	\([^ ]*\)$,\2 \1," -e "s,, ,g" @mined.$$6 > @mined.$$7
if exist @mined.bak del @mined.bak
ren @mined.mar @mined.bak
ren @mined.$$7 @mined.mar
del @mined.$$?
dir @mined.*
