UNIX Script - setting dynamic variables (indirect variable reference)

后端 未结 2 708
别那么骄傲
别那么骄傲 2021-01-25 11:55

How to set shell variables from an input file ?

hello,

I need to set dynamic variable from an .ini file in a shell script.

Assume the input file is in

相关标签:
2条回答
  • 2021-01-25 12:26

    Solved

    using :

    file="install.ini"
    while IFS== read -r f v
    do
      eval "$f=$v"   
    done <"$file"
    

    did the trick.

    0 讨论(0)
  • 2021-01-25 12:35
    source input.ini
    

    Or

    . input.ini
    

    More info

    <source | .> filename [arguments]
        Execute commands from a file in the current shell.
    
    0 讨论(0)
提交回复
热议问题