I am trying to write a shell script that will such in data from a config file. The script should mount device nodes that are contained in a config file in the following format:
# filesystem type # read/write #device # Mount Point
xfs w /dev/sda1 /mnt
ext3 r /dev/hdc /mnt1
I then want to place the data into a variable so I can do something in the script like so:
mount -t xfs w /dev/sda1 /mnt
I need to have comments in the config file so need to ignore them when sucking in the configuration.
So, assuming that I have a config file as formatted above named mounts.cfg and the following shell script:
FILE="./mounts.cfg"
while read line
do
if [ -z "echo $line | sed '/^ *#/d;s/#.*//'" ]
then
next;
else
mount -t echo "$line | sed '/^ *#/d;s/#.*//'`";
fi
done < $FILE
but it gives me errors as apparently even though I am using sed to get rid of commented lines the variable still has some value associated with it. There has to be a better way to do this? any suggestions would be appreciated.
Thanks
Phil