Export variables defined in another file

后端 未结 3 1172
遇见更好的自我
遇见更好的自我 2020-12-30 04:58

I have a script that contains a couple of variables that need to be set as an environment variable

The list of variables change constantly and modifying it on my end

3条回答
  •  感情败类
    2020-12-30 05:31

    Are you looking for the '.' command (also spelled 'source' in bash):

    source foo.sh
    

    Since you need to export them to the environment as well, you may need to do a little extra work:

    while read -r line; do
        export "$line"
    done < foo.sh
    

提交回复
热议问题