Bash: Read Variables from Text-File VAR=VALUE Format

喜夏-厌秋 提交于 2019-12-11 13:44:50

问题


I want to load some variable from a text file into my batch script. I tried searching but I only find tips for files like

VALUE1
VALUE2
...

My TEXT-File has the following format:

VER=123
MIN_VER=123456789
TARGET_VER=132456790

And I want to be able to load this file so that I can access the three variables for matching it against a number in bash. How can I achieve this?


Answered! Thanks!


回答1:


Save your variables to file like you want (VAR=VAL) and run:

. ./your_file

Maybe there will have to be"#!/bin/bash" at the beginning of this file. False



来源:https://stackoverflow.com/questions/11603349/bash-read-variables-from-text-file-var-value-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!