0 votes
1 view
in DevOps and Agile by (30k 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 (51.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 !