Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

sed - find&replace - in multiple files

$
0
0
Hello
I have 60+ *.xhtml files

I have to find particular phrase (e.g. <h3 id="top">) which includes spaces, <, ", etc.
and replace it with another phrase
(e.g. <a class"top" href="../file/file.xhtml>), also with spaces and other 'characters'.

I tried to use sed:
Code:

find . -name "*.xhtml" | xargs sed -i 's/<h3 id="top">/<h3 id="top"><a class="tyt" href="http://forums.opensuse.org/english/get-technical-help-here/Text/text.xhtml">/g'
and have error:
Code:

sed: -e expression #1, char 54: unknown option to `s'
or
Code:

find . -name "*.xhtml" | xargs sed -i 's/'<h3 id="top">'/'<h3 id="top"><a class="tyt" href="http://forums.opensuse.org/english/get-technical-help-here/Text/SpisTresci.xhtml">'/g'
with this error
Code:

syntax error near unexpected token `<'
or
Code:

find . -name "*.xhtml" | xargs sed -i 's/"<h3 id="top">"/"<h3 id="top"><a class="tyt" href="http://forums.opensuse.org/english/get-technical-help-here/Text/SpisTresci.xhtml">"/g'
with error
Code:

sed: -e expression #1, char 57: unknown option to `s'
What shall I do?
Any proper way of entering this command?
Any help?
Or how to do that?

greetings

Viewing all articles
Browse latest Browse all 40713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>