linux Bash cat ->将字符串分隔到新行[duplicate]

vnzz0bqm  于 2022-12-29  发布在  Linux
关注(0)|答案(1)|浏览(111)
    • 此问题在此处已有答案**:

How do I replace a string with a newline using a bash script and sed?(7个答案)
5天前关闭。
当我使用cat file_name.txt时,我得到的日志在一行中。如何将每个字符串分隔到新行中?

"Rest API SRV01""Rest API SRV02""Rest API SRV01"

预期产出:

"Rest API SRV01"
"Rest API SRV02"
"Rest API SRV01"
avwztpqn

avwztpqn1#

一种方法是将每个""替换为"\n

sed 's/\"\"/\"\n\"/g' <<< '"Rest API SRV01""Rest API SRV02""Rest API SRV01"'
"Rest API SRV01"
"Rest API SRV02"
"Rest API SRV01"

相关问题