I'm trying to make a configuration file to help running a bash script.
The idea is having a file (script.conf) like this
directory=c:/path/to/a/specific/directory/
logo=y
title=y
hotspots=n
combobox=n
Then, running the script, it will read script.conf and get those variables to use in the script.
How can I do that?
The source
command (also known as .
, but not to be confused with the directory of the same name) will allow you to run another file in the current shell. Simply make that file contain variable assignments.
foo.sh
#!/bin/bash
. bar.sh
echo "$baz"
bar.sh
baz=42
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With