I want to source a file in bash script. I know we can do -
. /path/to/file/file.cfg OR source /path/to/file/file.cfg
But I am writing a single bash script in the world of Python scripts and need to use a config file created for Python scripts -
Python config file -
[section 1] param1=val1 param2=val2 [section 2] param1=val11 param2=val22
bash script -
source /path/to/python_config_file echo $param1
Error I get -
/path/to/python_config_file: line 1: $'[section 1]\r': command not found
I tried to remove the [ ] lines -
source `sed -e 's/\[[^]*\]//g' /path/to/python_config_file` echo $param1
It dumps all the variables as output -
source $'\r' $'param1=val1\r' $'param2=val2\r' $'param1=val11\r' $'param2=val22\r'
: No such file or directory + echo
How do I resolve this? I know I can create a config file for bash but the issue is that the client doesn't want multiple config files as it'll become maintenance nightmare plus python + bash configs have to be synced.