I am a newbie at making bash scripts, but I was wondering if it is possible to store, recall, and modify variables for use in bash scripts inside of a config file. For example, you could have a 10 line file that stores 10 variables, and when executing the script it could get the needed variables out of that file, and then write any changes afterwards.
My reasoning is that while I don't know all the intricacies, I'm pretty sure variables get lost after reboots, or when ran by different users, or if the command is ran in a subshell, etc. This way they would basically be permanent until changed, as well as easy to view all at once.
A couple examples for their use would be
If you want to keep track of how many times a script was run, it could basically go (in improper syntax)
"var4=line 4 of config file; echo script has been ran $var4 times; write var4+1 to config file"
Or if you want to create a new folder every time the script is ran, it could just be along the lines of
var6= line 6 of conf file; mkdir directory$var6; write var6+1 back to config file.
If this is a good way to handle semi permanent variables, then what is the best way to read/store them?
I'm actually pretty sure I could get this working with sed, but being such a newbie, I figured I would ask if this is the most efficient way to do this, or if there is perhaps a much better way to store and access "permanent until changed" variables.