Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)

I have a parameters.ini file, such as:


    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.


# 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?

1 Answer

0 votes
by (50.2k points)

Use the below command using awk 

version=$(awk -F "=" '/database_version/ {print $2}' parameters.ini)

As per your question, this single liner will grab your ini value within the shell script 

This is useful for basic INI files, if it has 2 [parameters.ini] this will return the value twice

And to remove that we can use specialized ini parser like crudini.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers


104k users

Browse Categories