I am fairly new to running scripts in UNIX/Linux. I have a .env file containing environment information and a .sh script containing folder creations etc for that environment.
How would I run the script on the environment contained in the .env file or how could I point the script to the target environment?
Would it be as easy as:
bash 'scriptname.sh' 'filename.env'
You need to source the environment in the calling shell before starting the script:
source 'filename.env' && bash 'scriptname.sh'
In order to prevent polution of the environment of the calling shell you might run that in a sub shell:
(source 'filename.env' && bash 'scriptname.sh')
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