#!/bin/bash

declare -r LIVE_DIRPATH="/Library/WebServer/Documents/data/sc_data"
declare -r WORK_DIRPATH="/Users/janvier/Sites/data/sc_data"

declare -ar SC_LIST=(
  "omni_m"
  "stereoa"
  "stereob"
)

declare cr_num="${1}"

declare regex=""
declare live_sc_data_filepath=""
declare work_sc_data_filepath=""

for sc in ${SC_LIST[@]}; do
  regex="cr${cr_num}/${sc}-????????-????????.dat"
  live_sc_data_filepath="$(ls -1 ${LIVE_DIRPATH}/${regex} 2> /dev/null)"
  work_sc_data_filepath="$(ls -1 ${WORK_DIRPATH}/${regex} 2> /dev/null)"

  if [[ -f "${live_sc_data_filepath}" && -f "${work_sc_data_filepath}" ]]; then
    printf "diff %s %s\n" "${live_sc_data_filepath}" "${work_sc_data_filepath}"
    diff "${live_sc_data_filepath}" "${work_sc_data_filepath}"
    printf "\n"
  fi
done

exit 0
