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