How do I use a new-line replacement in a BSD sed?

后端 未结 4 972
栀梦
栀梦 2020-11-29 07:20

Greetings, how do I perform the following in BSD sed?

sed \'s/ /\\n/g\'

From the man-page it states that \\n will be treated literally with

4条回答
  •  醉酒成梦
    2020-11-29 07:54

    For ease of use, i personally often use

    cr="\n" 
    # or (depending version and OS)
    cr="
    "
    
    sed "s/ /\\${cr}/g"
    

    so it stays on 1 line.

提交回复
热议问题