I have a bash script which works like this;
.
├── script.sh
├── configs
| ├── conf1.conf
| └── conf2.conf
script.sh
;
#!/bin/bash
function test {
echo $var1
}
case $1 in
$1) cfg=$1 ;;
esac
cfg_file=~/config/"$cfg.conf"
if [ -f "$cfg_file" ]; then
. "$cfg_file"
test $1
else
echo "$1.conf doesn't exist"
exit 1
fi
conf1.conf
;
var1=test1
conf2.conf
;
var1=test2
So in this script, if you run ./script.sh conf1
then it will use the conf1.conf
file and will print test1
from var1
to shell. Same apply for conf2
and so on.
I'm trying to change the source of the config files to a remote source like this;
cfg_file='http://example.com/configs/"$cfg.conf"'
I've tried this very code above but it couldn't locate the config file.
How can I do this in bash, if possible?