#! /bin/sh
# a trivial utility for getting the data out of the logs
# this file is part of FormCalc
# last modified 11 Jan 07 th


if [ $# -eq 0 ] ; then
  echo "Usage:  $0 DIR"
  echo ""
  echo "Extracts the data from the log files DIR/*"
  echo "and writes them to the file DIR.data."
  echo ""
  exit 1
fi

files=""
out=""
for arg in $* ; do
  [ -d $arg ] && arg="$arg/*"
  files="$files $arg"
  [ -z "$out" ] && out=`dirname "$arg"`.data
done

echo $out

( for file in $files ; do
  sed -n '
	s/^|//
	t 1
	b
	: 1
	N
	s/\n|+//
	t 1
	P
	D' $file
done ) > $out

