Page 1 of 1

Sed script seems not to work with variables (Solved)

Posted: Sun Nov 01, 2020 7:53 pm
by taersh

Code: Select all

sed -i 's/<Pager\/>/\n<TrayButton popup="$TEXTPOPUP" icon="$ICON" border="true">exec:$EXEC<\/TrayButton>\n<Pager\/>/g' /root/.jwmrc-tray

The code seems not to work with variables.
When I'm using it exactly like the above example, the content of variables is not put into the result. Instead the variables equal to the above code are put into /root/.jwmrc-tray.

When I'm using this modification

Code: Select all

sed -i 's/<Pager\/>/\n<TrayButton popup="'$TEXTPOPUP'" icon="'$ICON'" border="true">exec:'$EXEC'<\/TrayButton>\n<Pager\/>/g' /root/.jwmrc-tray

nothing changes inside /root/.jwmrc-tray.

What's wrong with that code or with what I'm doing?


Re: Another sed problem (Solved)

Posted: Sun Nov 01, 2020 8:24 pm
by taersh
Ok, I found the problem myself.

Variable $TEXTPOPUP contains spaces, so I had to double quote the variable!

Code: Select all

popup="'"$TEXTPOPUP"'"
Now it works well. :D