How do I grab an INI value within a shell script?

来源:互联网 发布:linux cat 分页 编辑:程序博客网 时间:2024/05/17 07:44


I have a parameters.ini file, such as:
[parameters.ini]
    database_user    = user
    database_version = 20110611142248
I want to read in and use the database version specified in the parameters.ini file from within a bash shell script so I can process it.
#!/bin/sh

# Need to get database version from parameters.ini file to use in script

php app/console doctrine:migrations:migrate %DATABASE_VERSION%
How would I do this?

 

one of more possible solutions
dbver=$(sed -n 's/.*database_version *= *\([^ ]*.*\)/\1/p' < parameters.ini)
echo $dbver
 

0 0
原创粉丝点击