A shell script question

Hi,
I have a file say xmldir.conf. This is a flat file which contains the data in specific format not other then this. The format is
/backup/surjya/mvfile,noeof
/backup/surjya/mdbase,eof
/backup/surjya/mdbaseso
/backup/surjya/trial,hoeof
/backup/surjya/test,eof
The field before "," is directory names and field after "," is an attribute of the directory. I have written a shell script to list out the directory names from xmldir.conf file according to the attribute. Those names will be listed only if attribute is noeof or eof. If no attribute is there like 3rd row of the file then it is treated as also eof attribute.
Now my program is

#!/bin/sh
conffile=xmldir.conf
dir=`cut -d, -f1 xmldir.conf`
echo $dir
for dir1 in $dir
do
insertmode=`grep $dir1 $conffile | awk '{FS = ","} {print$2}'`
echo $insertmode
#echo $dir1 $insertmode
if [ $insertmode = "eof" -o $insertmode = "" ]
then
echo "It is eof dirs" $dir1
else if [ $insertmode = "noeof" ]
then
echo " It is noeof dirs" $dir1
fi
else
echo " It is neither of these"
fi
done

But it is not working. It fails when it is checked for rows without atribute. So please let me know how can I correct this.

Thanks

Check this out and pick up from there.

[~/temp]$ cat surya.ksh
#! /bin/ksh

while read line
do
ATTR=$(echo $line | awk -F"," '{ print $2 }')
#echo -$ATTR-
if [[ "${ATTR}" == "noeof" ]] ; then
echo "noeof:$line"
elif [[ "${ATTR}" == "eof" || "${ATTR}" == "" ]] ; then
echo "eof:$line"
fi ;
done < surya.txt
[~/temp]$ cat surya.txt
/backup/surjya/mvfile,noeof
/backup/surjya/mdbase,eof
/backup/surjya/mdbaseso
/backup/surjya/trial,hoeof
/backup/surjya/test,eof
[~/temp]$ ./surya.ksh
noeof:/backup/surjya/mvfile,noeof
eof:/backup/surjya/mdbase,eof
eof:/backup/surjya/mdbaseso
eof:/backup/surjya/test,eof

vino

Can you try this:

sed -n -e '/,/!p' -e '/,eof$/p' -e '/,noeof$/p' xmldir.conf|awk -F"," '{print $1}'

Would be really interested to know whether this is what you wanted.