I'm trying to script changes in a config file (/var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
), which boils down to:
[Update already installed software]
Identity=unix-group:admin;unix-group:sudo
Action=org.debian.apt.upgrade-packages
ResultActive=yes
[Printer administration]
Identity=unix-group:lpadmin;unix-group:admin;unix-group:sudo
Action=org.opensuse.cupspkhelper.mechanism.*
ResultActive=yes
[Disable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=no
I'm trying to set ResultActive=yes
for all blocks that start with [Disable hibernate
. Using sed and regex groups I came up with:
sed -i 's/\(Disable hibernate.*\n.*\n.*\nResultActive\=\)no/\1yes/' /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
However this does not change the file. According to regexr, the regex matches, but checking with sed.js.org, sed doesn't change a thing.
How can I fix my sed
command, to change the appropriate line for the hibernate config blocks?
edit: It seems like I cant get sed
groups with newlines not to work at all.
sed
reads line by line. This means there are no newlines in the pattern space to match. – Kusalananda♦ Jan 27 '20 at 11:25