how to replace two things at once with sed?

后端 未结 2 1220
野趣味
野趣味 2021-01-31 17:46

Given is string: dog apple orange banana

I need to make it: monkey apple cow banana

That is without calling sed twice.

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-31 18:09

    The following sed example should solve your problem. sed allows multiple -e switches, which allows you to replace more than one thing at a time.

    sed -e 's/dog/monkey/g' -e 's/orange/cow/g'
    

提交回复
热议问题