For example. I have 2 discrete scripts, which I want to remain and run separately. Script 1 utilizes a read function asking for a desired filename lets just say name1, does it's thing, and outputs the file with name1.
I need the second script to utilize name1 as part of an input, as well as a configuration file separate from the script that is able to point to name1 [assuming directory is fixed, but file name is variable.]
To do this, I imagine I'd need a way to export a global variable The way I have it now looks something like this:
read -p "What do you want this file to be called?: " name1 export name1=$name1
running the following as
yields the correct results, but how can I replicate this behaviour without having to specify run the script in the current shell with . - assuming that the next person would just run ./script1.sh or something, is there a way to export globally? This way I could use the variable $name1 in both the config file as well as script2.
Many thanks in advance.