#!/bin/bash
OLD_IFS=$IFS
IFS=','

INFILE="$1"
PROFILE="$2"

# remove leading whitespace, comments and empty lines
cat $INFILE|sed -e 's/^ *//'|sed -e '/#/d'|sed -e '/^$/d'| while read a b c d
do

if [[ "$a" =~ ^$ ]]
then
echo [blank]
else
if [ "$a" == "$PROFILE" ]
then
echo found requested profile
echo profile: ${a} 
foo=`echo $b|sed -e 's/(//'|sed -e's/)//'`
bar=`echo $c|sed -e 's/(//'|sed -e's/)//'`
baz=`echo $d|sed -e 's/(//'|sed -e's/)//'`
IFS=' '
set -- $foo
fwd_profile=( ${*} )
echo fwd_profile:  ${fwd_profile[*]}
set -- $bar
rev_prof=( ${*} )
echo rev_prof: ${rev_prof[*]} 
set -- $baz
intervals=( ${*} )
echo intervals: ${intervals[*]}
echo
fi
IFS=','
fi

done 
IFS=$OLD_IFS