Sed example for updating a value in a block in a config file
Thanks to Jason Montleon for the example
[jmontleo@jmontleo ~]$ cat alpha.txt [lazy] #enabled: false [foo] #enabled: false [jmontleo@jmontleo ~]$ sed -i '/^\[lazy\]$/{$!{N;s/^\[lazy\]\n#enabled: false$/[lazy]\n#enabled: true/;ty;P;D;:y}}' alpha.txt [jmontleo@jmontleo ~]$ cat alpha.txt [lazy] #enabled: true [foo] #enabled: false
Reference: http://unix.stackexchange.com/questions/26284/how-can-i-use-sed-to-replace-a-multi-line-string