-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
  • 679
  • 1
  • 9
  • 23

2 Answers2

1

Try this:

echo '</test>' | sed 's|</test>|</test1>|'
Cyrus
  • 84,225
  • 14
  • 89
  • 153
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
  • 730,956
  • 141
  • 904
  • 1,278