I'm trying to pass a flatdb with some names through a script in order to ignore certain things fields and check others. Currently this is as far as I've gotten.
What would I use in my then statement in order to ignore the comment and space lines?
EDIT: Sample of file being read
Bob,Brown,Smith,39
#Alex,Jay,Jones,83
Justin,Michael,White,18
James,Paul,Weis,54
EDIT: Then I am separating each name
IFS_SAVE=${IFS}
IFS=,
while read value1 value2 value3 value4
do
echo "First name ${value1}"
echo "Middle name ${value2}"
echo "Last name ${value3}"
echo "Age ${value4}"
done < ${1}
Then I'm trying to ignore blank lines in the file
while read value1 value2 value3 value4
do
if [ -z ${value1} ]
then
echo "blank line exists"
fi
done < ${1}
Then I'm trying ignore commented lines in file
while read value1 value2 value3 value4
do
if [ "${value1:0:1}" = "#" ]
then
echo "comment exists"
fi
done < ${1}
From here down I have been unable to get this to actually work
I'm trying to check if fields start or end with space
while read value1 value2 value3 value4
do
if [[ ${value1} = *[[:space:]]* ]]
then
echo "space exist"
fi
done < ${1}
EDIT: Ideal output
First name Bob
Middle name Brown
Last name Smith
Age 39
First name Justin
Middle name Michael
Last name White
Age 39
James,Paul,Wise,54 space exist