#!/bin/bash
n=0
>bord
for f in cell??.pbm; do
   out=$(basename $f .pbm)
   echo $f $out
   tesseract $f $out --psm 10 --tessdata-dir . -l digits -c tessedit_char_whitelist=123456789
   x=$(cat $out.txt)
   x=${x:-.}
   echo -n "$x " >>bord
   n=$(expr $n + 1)
   r=$(expr $n % 3)
   if [ $r = 0 ]; then
      echo -n '  ' >>bord
   fi
   r=$(expr $n % 9)
   if [ $r = 0 ]; then
      echo >>bord
   fi
   r=$(expr $n % 27)
   if [ $r = 0 ]; then
      echo >>bord
   fi
done
echo >>bord
