Need bash shell script for reading name value pairs from a file

后端 未结 7 1177
长发绾君心
长发绾君心 2020-11-30 02:25

I have a file like

name1=value1
name2=value2

I need to read this file using shell script and set variables

$name1=value1
$n         


        
7条回答
  •  执笔经年
    2020-11-30 03:16

    If all lines in the input file are of this format, then simply sourcing it will set the variables:

    source nameOfFileWithKeyValuePairs
    

    or

    . nameOfFileWithKeyValuePairs
    

提交回复
热议问题