5

Let us say I have a txt file vars.txt like this.

VAR1=32 VAR2=47 VAR3=78 

Now if I simply do source vars.txt, these variables won't be exported as environment variables because I didn't prefix them with export.

So, my question is, is there a way to export all those variables without having to prefix them with export in the file?

1 Answer 1

5

Yes, there is a way: set -a

From help set

Options:
-a   Mark variables which are modified or created for export.

To export every variable in your file you would do

set -a source yourFile set +a 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.