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

2019-07-23 21:03发布

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条回答
混吃等死
2楼-- · 2019-07-23 21:21

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

查看更多
登录 后发表回答