#! /bin/bash
# Last edited on 2024-12-21 20:53:01 by stolfi

tfile="/tmp/$$.sdnd"

cat \
  | gawk \
      ' // { 
          ck = $1; sz = $2; dt = $3; fn = $4; 
          if (match(fn, /[\/][^/]*$/))
            { dir = substr(fn, 1, RSTART)
              nam = substr(fn, RSTART + 1)
              printf "%010d.%08d.%s %s %s\n", ck, sz, nam, dt, dir
            }
        }
      ' \
  | sort \
  > ${tfile}
  
cat ${tfile} \
  | gawk \
      ' BEGIN { olin = ""; okey = ""; odup = 0 }
        // { 
          key = $1; 
          if (key == okey)
            { print olin; odup = 1; }
          else
            { if (odup) { print olin; print ""; }
              odup = 0;
            }
          olin = $0; okey = key;
        }
        END { if (odup) { print olin; } }
      ' 
