[Solved] Substitute text in multi line string

a2tmk

New Member
Joined
Mar 1, 2022
Messages
29
Reaction score
22
Credits
240
As part of a post-install script I have a one-liner which copies a GTK theme and gives it a new name, I also want to include in the script a command that will change the font colour of the newly created theme from -

CSS:
textview text {
  color: #303030;
  background-color: #ffffff; }

to -

CSS:
textview text {
  color: #000000;
  background-color: #ffffff; }

I've looked up various online solutions for substituting text in multi line strings using SED, AWK and Perl and tried to adapt them with no success.

Any help would be gratefully received.

Cheers, DM.
 


kibasnowpaw

Active Member
Joined
Jan 2, 2022
Messages
179
Reaction score
99
Credits
1,473
That reminds me of the good old days when I made my own homepage.
PS. I don't do scripting so I can't help you.

apti.png
 
OP
A

a2tmk

New Member
Joined
Mar 1, 2022
Messages
29
Reaction score
22
Credits
240
A bit of further digging and I've come up with a workable solution.

The following best answer on stackoverflow searches for a particular line of text and then replaces the following line.

In my case textview text { is a unique line in the file that I'm working on so this solution works for me.

Bash:
sed -i '/textview text {/!b;n;c color: #000000;' gtk.css

Marking as solved but if anyone has any further input or ideas I'd be interested to hear them.
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Staff online

Members online


Latest posts

Top