如何用sed一次替换两件事? [英] how to replace two things at once with sed?

查看:39
本文介绍了如何用sed一次替换两件事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定的是字符串:dog apple orange orange

我需要做到:monkey apple cowbanana

那就是没有调用 sed 两次.

That is without calling sed twice.

推荐答案

以下 sed 示例应该可以解决您的问题.sed 允许使用多个 -e 开关,这允许您一次替换多个内容.

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'

这篇关于如何用sed一次替换两件事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆