Trying to write a one liner to change my wallpaper through a config file. Tried adapting from: Replace regex capture group content using sed but I can't seem to get it right.
My config file contains the following string:
output * bg ~/pictures/wallpapers/old-wallpaper.jpg fill
I want to change the path in this string to something else.
This one makes most sense to me but doesn't capture correctly:
sed "/output \* bg /s|.* fill|~/path/to/foobar.jpg fill|" sed_file
output * bg ~/pictures/wallpapers/old-wallpaper.jpg fill
This one looks completely wrong but seems to get the job done. Although I think it replaces anything that starts with output
.
sed "/output \* bg/s| .* fill| \* bg ~\/path\/to/foobar.jpg fill|" sed_file
output * bg ~/path/to/foobar.jpg fill
awk '/^output/{ $4="foo" } { print }' file
– Cyrus Dec 30 '21 at 23:54awk '/^output \* bg/{ $4="foo" } { print }'
– mork Dec 31 '21 at 00:02