Read from other file

Hi,

I am building a shell script.

i have another file test.conf which has below information.

env = PROD
subdomain = test

When I process the other shell script. it should check this test.conf and see if it is prod. If the env is prod it should build a URL using subdomain like below.

https://test.krish.com 

If the conf file has info like below.

env = test
subdomain = IIS7

then it should take

http://test.krish.com

How can i achieve this. I will have to URL in my original shell script.

Thannks,
Krish.

The following function is certainly helpful

getconf() {
awk -F '[ =]' '$1==key {print tolower($2)}' key="$1" test.conf
}

Now you can do e.g.

if [ `getconf env` =  prod ]; then
 echo "This is prod"
else
 echo "This is test"
fi 

Try

URL="http"$(grep -q "env = PROD" file && printf "s")"://test.krish.com"
echo $URL
https://test.krish.com