I want to combine two sed command in one and really don't know how to do it, I've tried multiple things without success.
For the result I want all slash between a specific tag to be replaced with backslash, what would result in :
Source :
<FilePath>a/b/c/d</FilePath> <OtherTags>Bob</OtherTags> <FilePath>1/2/3/4</FilePath>
Result :
<FilePath>a\b\c\d</FilePath> <OtherTags>Bob</OtherTags> <FilePath>1\2\3\4</FilePath>
I've found this command to change text between tags :
sed -i -e 's/\(<FilePath>\).*\(<\/FilePath>\)/<FilePath>TEXT_TO_REPLACE_BY<\/FilePath>/g' test.txt
But this command replace all the text... So what I want is to keep the text and only replace the slash with backslack with this kind of command :
sed -e 's/\\/\//g' test.txt
But I struggle to combine those two.
Thanks for your help.
<
or>
inside the tags (and in particular no nested tags)? Otherwise you really need a library that can parse XML properly./
with\
inside of<OtherTags>
, it'd have been useful for us testing if you had included in your example lines where the text within<OtherTags>
included/
s. JustBob
doesn't give us anything to test with to prove if a potential solution works or not.Bob/Smith
would have been much more useful