I'm working on a script layout to have "theming scripts", that is, to be able to change lots of things appearance with just a command =P
I came to the conclusion that I will need to learn sed, and I'm on it. But some handy help would come great now =D
The only thing that rests unchangeable to me is my Openbox theme. There is a config file called
rc.xml on
~/.config/openbox with a line that simply encloses the theme name between
<theme><name></name></theme>
Now, I learned that with sed I can use
-i option to take the input from the same file where I write the output. I asked for help on Freenode #Bash, but got a quickly "no" and a recommendation to use portable tools, like ed instead of sed. Is that advisable?
In any case, I found some lines on a script that seems to do something similar:
Code:
CFGDIR=$HOME/.config/openbox
cat $CFGDIR/rc.xml > $CFGDIR/rc.temp
sed -e "/<theme>/{n;s/\(<name>\).*\(<\/name>\)/\1$1\2/;}" $CFGDIR/rc.temp > rc.xml
Tell you what I don't get:
- The use of the
-e option in this case. I'd understood that it's used to have multiple replacements on the same sed instance.
- The
{n;s part.
- Why it uses parentheses.
Thanks for your time!