#!/bin/sh
#liste des "sources" enregistrees sous Amas
OUT1=/tmp/baoils.$$
ils /baoradio/data/AmasNancay/ > ${OUT1}
OUT2=/tmp/baoawk1.$$
awk '($1=="C-") {print $2}' ${OUT1} > ${OUT2}


#Sequence 
tableau=( `cat $OUT2 | awk '{print $1}'` )
IFS='
'
tableau=( $( printf "%s\n" "${tableau[@]}" | awk 'x[$0]++ == 0' ) )

for i in ${tableau[@]}
do
  echo "source $i"
  OUT3=/tmp/baosource.$$
  listedate=( `ils $i | awk '($1=="C-"){print $2}'`)
  IFS='
'
  listedate=( $( printf "%s\n" "${listedate[@]}" | awk 'x[$0]++ == 0' ) )
 
  ntotfiles=0
  for j in ${listedate[@]}
  do
    nfiles=`ils ${j}/Fiber1/ | wc -l`
    echo ">>> $j ---> $nfiles"
    let "ntotfiles=ntotfiles+nfiles"
  done 
  echo "total files = $ntotfiles"

done
