在UNIX中替换下一个字符串

时间:2016-03-04 21:49:08

标签: unix

我是UNIX新手。如何将“the”的下一个单词替换为“there”?

我知道s/\<the\>/there/可以取代第一次出现的&#34;&#34;在线。教科书上写着:n – search forward for the next occurrence of the text searched previously.

但是在哪里放&#34; n&#34;?

1 个答案:

答案 0 :(得分:0)

将数字放在最后,您期望g

echo "This is the test of replacing the third word the by there" | sed 's/\<the\>/there/3'
This is the test of replacing the third word there by there