如何在 BSD sed 中使用换行符? [英] How do I use a new-line replacement in a BSD sed?

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

问题描述

您好,我如何在 BSD sed 中执行以下操作?

Greetings, how do I perform the following in BSD sed?

sed 's/ /
/g'

从手册页中可以看出 将在替换字符串中按字面意思处理,我该如何避免这种行为?有替代品吗?

From the man-page it states that will be treated literally within a replacement string, how do I avoid this behavior? Is there an alternate?

我使用的是 Mac OS Snow Leopard,我可能会安装 fink 以获得 GNU sed.

I'm using Mac OS Snow Leopard, I may install fink to get GNU sed.

推荐答案

在 shell 中,你可以:

In a shell, you can do:

    sed 's/ /
/g'

在反斜杠后按回车键插入换行符.

hitting the enter key after the backslash to insert a newline.

这篇关于如何在 BSD sed 中使用换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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