#!/bin/bash

# Shows the aggrogated SETI results by type

set -euo pipefail

if [ $# -lt 1 ]; then
  echo 1>&2 "missing run id (pipeline id) arg"
  exit 2
fi

if [ ! -d "/mnt/nautilus_rw/sim/seti/$1" ]; then
  # directory doesn't exist if no interesting scenarios were found
  echo no scenarios found
  exit 0
fi

# Find all subdirectories and count .txt
find /mnt/nautilus_rw/sim/seti/$1/* -maxdepth 1 -type d -print0 |
while
  IFS= read -r -d '' i ;
  do echo -n $i" " | sed -e "s/^.*\///" ;
  (find "$i"/*.txt -type f | wc -l) ;
done
