#!/bin/sh
cat "ships.gophermap"
find "/var/gopher/" -maxdepth 1 ! -path "/var/gopher/" ! -path "/var/gopher/ships" ! -path "/var/gopher/log" -type d -print | sed 's|/var/gopher/||' | sort | while read -r ship
do
  entry_num=$(grep -c "^0${ship}" "/var/gopher/listing.gophermap")
  if [ "$entry_num" != "0" ]; then
    printf "1%s (%s)\\t/ships/%s/\\n" "$ship" "$entry_num" "$ship"
  fi
done
