example.ini
UNIVER_SEARCH_VIDEO=http://127.0.0.1/api/search/common
UNIVER_MONGO_URL=mongodb://127.0.0.1
UNIVER_SEARCH_LABEL=http://127.0.0.1api/search/common
UNIVER_USER_LOGIN=http://127.0.0.1/api/login
UNIVER_TASK_MANAGER=http://127.0.0.1/api/task/manager``
I want to read these five values from example.ini and assign them to environment variables. How can I do that?
newcomers are not very good at writing, just have a rough demo
< H2 > continue to ask for help < / H2 >the content of my current environment-variable.ini file is
UNIVER_USER_LOGIN=http://127.0.0.1/api/login
UNIVER_SEARCH_ORDINARY=http://127.0.0.1api/search/common
UNIVER_SEARCH_LABEL=http://127.0.0.1/api/search/common
UNIVER_SEARCH_VIDEO=http://127.0.0.1/api/search/common
UNIVER_TASK_MANAGER=http://127.0.0.1/api/task/manager
UNIVER_PROJECR_URL=567.110.220.11
UNIVER_PROJECR_PORT=667777760011
I execute orders
-sharp!/bin/bash
grep "UNIVER_USER_LOGIN" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_LABEL" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_VIDEO" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_VIDEO" environment-variable.ini >> /etc/profile
grep "UNIVER_TASK_MANAGER" environment-variable.ini >> /etc/profile
grep "UNIVER_PROJECR_URL" environment-variable.ini >> /etc/profile
grep "UNIVER_PROJECR_PORT" environment-variable.ini >> /etc/profile
source /etc/profile
:<<!
if [ $UNIVER_SEARCH_VIDEO ]; then
echo ${UNIVER_SEARCH_VIDEO}
else
echo ""
fi
the original environment variables that are not available cannot be modified, such as this environment variable UNIVER_PROJECR_PORT
how to optimize the code?
if there is an environment variable on the computer, you can modify the original environment variable
if there is no original, there will be no effect
< H1 > newly modified < / H1 >-sharp!/bin/bash
grep "UNIVER_USER_LOGIN" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_LABEL" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_VIDEO" environment-variable.ini >> /etc/profile
grep "UNIVER_SEARCH_VIDEO" environment-variable.ini >> /etc/profile
grep "UNIVER_TASK_MANAGER" environment-variable.ini >> /etc/profile
grep "UNIVER_PROJECR_URL" environment-variable.ini >> /etc/profile
echo "UNIVER_PROJECR_PORT="xxx"" >> /etc/profile
sed -i "/UNIVER_PROJECR_PORT/s/xxx/79000000/g" /etc/profile
grep "UNIVER_PROJECR_PORT" environment-variable.ini >> /etc/profile
source /etc/profile