Bash:如何在osx bash中用新行替换字符串? [英] Bash: How can I replace a string by new line in osx bash?
本文介绍了Bash:如何在osx bash中用新行替换字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我经常搜索它.我只想要这一行:
I am googling it a lot. I only want that this line:
echo "Replace <newLine> it by <newLine> NEWLINE <newLine> in my OSX terminal <newLine> and bash script" | sed -e 's/<newLine>/\n/g'
在我的osx终端和bash脚本中均可工作.我不能为此使用 sed
吗?还有另一种解决方案吗?
works in my osx terminal and in my bash script. I can't use sed
for this? Is there another one line solution?
推荐答案
此处正在使用sed
echo "Replace <newLine> it by <newLine> NEWLINE <newLine> in my OSX terminal <newLine> and bash script" | sed 's/<newLine>/\'$'\n/g'
这是一篇博客文章,解释了为什么-https://nlfiedler.github.io/2010/12/05/newlines-in-sed-on-mac.html
And here is a blogpost explaining why - https://nlfiedler.github.io/2010/12/05/newlines-in-sed-on-mac.html
这篇关于Bash:如何在osx bash中用新行替换字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文