我如何抓住一个shell脚本内的INI价值? [英] How do I grab an INI value within a shell script?
本文介绍了我如何抓住一个shell脚本内的INI价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个parameters.ini文件,如:
I have a parameters.ini file, such as:
[parameters.ini]
database_user = user
database_version = 20110611142248
我想在阅读和使用中的parameters.ini文件中指定的数据库版本从一个bash shell脚本中,所以我可以处理它。
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?
推荐答案
怎么样在该行grepping然后用awk
How about grepping for that line then using awk
version=$(awk -F "=" '/database_version/ {print $2}' parameters.ini)
这篇关于我如何抓住一个shell脚本内的INI价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文