#!/bin/bash

ls -ld ../[0-9]* | awk '{ print substr($NF,4); }' > ls.out


for DIR in `cat ls.out` ; do

  CFG=../$DIR/config.py
  VCUTOFF=`awk '/^ *v_cutoff/{ print $3; }' $CFG`
  SINI=`awk '/sinI_min/  && ($3 != "None"){ print "_SINI" }' $CFG`
  PV=`awk '/pV_min/    && ($3 != "None"){ print "_PV" }' $CFG`
  ASTAR=`awk '/astar_min/ && ($3 != "None"){ print "_ASTAR" }' $CFG`
  IZ=`awk '/iz_min/    && ($3 != "None"){ print "_IZ" }' $CFG`

  NAME=`echo $DIR | awk '{ gsub("[0-9]*_", ""); print; }'`
  OUT=$DIR"_family.list_"$VCUTOFF$SINI$PV$ASTAR$IZ

  echo "$NAME -> $OUT"
  awk -vNAME=$NAME '/^#/ || (NF==0){ print; } !/^#/ && (NF>1){ print $0 "	" NAME; }' < ../$DIR/family.list_WO_INTERLOPERS > $OUT

done


