#!/bin/sh
#############################################################
## Name : /public/scripts/access2csv.sh
## Purpose : Convert from Access to CSV format
## By : Yariv Sheizaf
## Date : 10-Jun-2001
## Arguments : 1 - Source file name
#############################################################
if [ $# -lt 1 ]
then
echo ""
echo "Usage: $0 <source-file-name>"
echo "Example: $0 asrc"
echo ""
exit 1
fi
SRCFILE=$1
if [ ! -f $SRCFILE ]
then
echo ""
echo "Source file is not exist. Exit..."
echo ""
exit 1
fi
TRGFILE=$SRCFILE.out
if [ -f $TRGFILE ]
then
echo ""
echo "Old target file exist. Overwrite it (y/n) ?"
read ANS
if [ "$ANS" = "y" ]
then
rm -f $TRGFILE
else
echo "exit..."
exit 1
fi
fi
sed 's/ - - \[/,/' $SRCFILE | sed 's/:/,/' | awk '{print $1","$4","$6","$7}' > $TRGFILE
echo ""
echo "The output file is: "$TRGFILE
echo ""
exit 0