简体   繁体   中英

How to export env variables from file in bash script

I need to export a lot of variables like export x1=1 export x2=2

I moved all variables in file .env and tried

source .env

After it I executed

printenv

and all of this variables were absent in the list of env variables. Also I tried export $(xargs <.env) But I have commented lines in .env file and I got following messages

#': not a valid identifier

So how can I export variables from file and skip commented lines?

尝试命名一个类似 variables.env 的文件,然后尝试 export variables.env echo $somevariable_name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM