首页 > 解决方案 > 如何在 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 命令

标签: unixsed

解决方案


echo $STRING| sed 's/\\n/\n/g

这行得通!


推荐阅读