Bash Script Properties File Using '.' in Variable Name

前端 未结 3 1986
说谎
说谎 2021-01-18 23:13

I\'m new to bash scripting and have a question about using properties from a .properties file within a bash script.

I have seen a bash properties file that uses\'.\'

3条回答
  •  青春惊慌失措
    2021-01-18 23:39

    dot is not allowed to be variable name. so you cannot just simply source the property file.

    What you can do is:

    "parse" the file, not source it. E.g. with perl, awk or grep to get the value of interesting property name, and assign it to your shell var.

    if you do want to set a var with dot in its name, you can use env 'a.b.c=xyz' and get the a.b.c from env output.

提交回复
热议问题