I am looking to make an install script for hifi-berry and a few other pieces of hardware. When config.txt didn't have sections, there was no risk of adding a line in the "wrong place".

With the sections (which seem like a really nice feature), adding lines to the right place strikes me as quite error prone.

Is anyone aware of an editor (before I write my own) which is capable of understanding enough structure of the config.txt to be able to add / remove / change values in the correct section(s)


sudo config_edit --platform=pi3 --EDID=asus_monitor --add 'dtoverlay=asus_touch_screen'
sudo config_edit --add 'dtoverlay=microphone'   # add to un-filtered section

See : Conditional filters in config.txt

  • You need to explain what "correct section" means. config.txt is a simple text file, editable with any editor. See raspberrypi.org/documentation/configuration/config-txt
    – Milliways
    Mar 12 at 10:56
  • Do you mean something like sed / awk - use regular expressions to change a known value to the new value + the known value. The other way would be to replace the whole of the line with what you want - much simpler in my mind (but I'm known to be a lazy programmer).
    – user130616
    Mar 12 at 13:57
  • @Andrew I was thinking that the new filter functionality made textual modifications difficult, as you need to track active filters, and optionally have to add filters. Finally if you add a filter, you may need to add [all] afterwards.
    – mksteve
    Mar 12 at 14:21

There is! Try using this: sudo nano /boot/config.txt

If you didn't know nano is pretty nice! It is not Vim but still good!

  • How would I use nano in an install script? I was hoping for something which would classify each line as part of the active filters, and allow me to edit only the relevant line from the input parameters.
    – mksteve
    Mar 14 at 8:28
  • Ok, sorry. I thought you wanted just to edit a file. Mar 14 at 15:14

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.