How to replace one character with two characters using tr

前端 未结 5 1527
栀梦
栀梦 2020-12-17 08:10

Can tr replace one character with two characters?

I am trying to replace \"~\" with \"~\\n\" but the output does not produce the newline.

$ echo \"a         


        
5条回答
  •  自闭症患者
    2020-12-17 08:16

    echo "asdlksad ~ adlkajsd ~ 12345" | sed 's/~/~|/g' | tr '|' '\n'
    

    --This will work perfect, since sed having a problem replacing \n

提交回复
热议问题