-1

I have a stumbling block with sed replace (Linux shell)

I need to replace

</test> 

to

</test1>

tried

sed -i 's/<\/test>/</test1>/g'

and similar variants -but still no luck...so thanks for any hint to try

Serge
  • 639
  • 1
  • 7
  • 22

2 Answers2

1

Try this:

echo '</test>' | sed 's|</test>|</test1>|'
Cyrus
  • 77,979
  • 13
  • 71
  • 125
0

For what you tried, you need to escape the slash in the replacement string:

sed -i 's/<\/test>/<\/test1>/g'

Or change the regex boundary marker character:

sed -i 's%</test>%</test1>%g'
Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229