如何解决如何在UNIX Shell脚本中将长数据库字符串拆分为多行?
我在数据库列中存储了以下字符串:
"Your ack was rejected due to the following reason: \n -- Invalid code received. \n \n Please correct the error and resend."
\n
是我要在其中分割行的换行符。
预期输出:
"Your ack was rejected due to the following reason:
-- Invalid code received.
Please correct the error and resend it."
请建议使用unix / sed命令
解决方法
setTodos
这行得通!
,可以使用echo
-e
选项启用反斜杠转义的解释。考虑到字符串可能包含特殊字符,将其用引号引起来很重要。无需使用sed
或awk
STRING=...
echo -e "$STRING"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。