using /etc/foo.config in shell script

I'm very very new to shell scripting (about 4 hours)
i've google'd till i can't google no more

is it possible to have store values in a config file .e.g

/etc/foo.conf

data=/home/
mount=/dev/sda1
size=1GB

and access these values from a shell script but also
be able to use dialog/zenity to replace the data with new values

or I'm I better manually editing the config and commenting it very well

I'm assuming foo.conf has simple key=value style entries with only = (no spaces) between them. If yes, you can just source it:

#!/usr/bin/ksh

. /etc/foo.conf
echo $data
echo $mount
echo $size

This initializes the variables as you can see in the output:

$ read_foo
/home/
/dev/sda1
1GB

Now you can prepare the zenity/dialog screen with existing values pre-populated and allow user to change them. Once the user is done, you can write it back using below (assuming user has write permissions):

cat > /etc/foo.conf <<-VALUES
$data
$mount
$size
VALUES

Break the task into multiple small parts & do lots of echo to verify what you are doing. Good luck.

thanks :smiley: just what i was looking for . now just how i can implement it , it's one thing knowing how to do it it's another thing doing it a real world script

I suggest you use a sample config file with only one parameter. Focus on finalizing the design with that. That will give you enough understanding to proceed.