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

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

    suppose the name of your file is some.properties

    #!/bin/sh
    # Sample shell script to read and act on properties
    
    # source the properties:
    . some.properties
    
    # Then reference then:
    echo "name1 is $name1 and name2 is $name2"
    

提交回复
热议问题