Why does sed not replace all occurrences?

前端 未结 2 1675
鱼传尺愫
鱼传尺愫 2020-11-29 01:06

If I run this code in bash:

echo dog dog dos | sed -r \'s:dog:log:\'

it gives output:

log dog dos

How can

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 01:42

    You have to put a g at the end, it stands for "global":

    echo dog dog dos | sed -r 's:dog:log:g'
                                         ^
    

提交回复
热议问题