Bash:如何在osx bash中用换行替换字符串?

Rod*_*igo 7 bash sed

我正在谷歌搜索它.我只想要这一行:

echo "Replace <newLine> it by <newLine> NEWLINE <newLine> in my OSX terminal <newLine> and bash script" | sed -e 's/<newLine>/\n/g'
Run Code Online (Sandbox Code Playgroud)

在我的osx终端和我的bash脚本中工作.我不能用sed这个吗?还有其他一线解决方案吗?

xeo*_*eor 18

这是使用sed

echo "Replace <newLine> it by <newLine> NEWLINE <newLine> in my OSX terminal <newLine> and bash script" | sed 's/<newLine>/\'$'\n/g'
Run Code Online (Sandbox Code Playgroud)

这是一篇博客文章解释原因 - https://nlfiedler.github.io/2010/12/05/newlines-in-sed-on-mac.html