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

后端 未结 7 1197
长发绾君心
长发绾君心 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:18

    if your file location is /location/to/file and the key is mykey:

    grep mykey $"/location/to/file" | awk -F= '{print $2}'
    

提交回复
热议问题