How can I change values of the .ini files via command line? (linux or windows)

For example I have a php.ini file:

display_errors = On
error_reporting = E_ALL & ~E_NOTICE

Now, I need be like this command:

MAGIC-COMMAND display_errors=Off error_reporting=E_ALL php.ini

And that options effective and write in php.ini file, and I have this content:

display_errors = Off
error_reporting = E_ALL
  • 3
    What have you tried? sed -i looks like a good start. – Kamil Maciorowski Aug 15 '18 at 16:53
  • How about vi php.ini and then edit from Linux command line accordingly with vi? Are you trying to just get a method to edit in the command line or do you need to automate the task with a script or some command you can just run over and over? – Pimp Juice IT Aug 16 '18 at 3:21
  • @KamilMaciorowski, I don't need a find and replace software, I need to a smart setter and getter. be like this for parse: github.com/rudimeier/bash_ini_parser – Nabi K.A.Z. Aug 16 '18 at 5:46
  • @PimpJuiceIT see latest comment. – Nabi K.A.Z. Aug 16 '18 at 5:47
  • "I need to a smart setter and getter" -- Is your question asking for software recommendation then? (which would be off-topic here, so think twice). sed is perfectly capable of doing the changes your question describes. If you need something "smart" then please edit the question and explain your requirements. All this aside, my point was your question doesn't show your research effort. It's like "write a script for me" (off-topic, we're not a script writing service; we can help you with your existing script though) or "find a software for me" (off-topic). See How to Ask. – Kamil Maciorowski Aug 16 '18 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.