Thursday, February 3, 2022

[SOLVED] Can't insert a new line and tab with sed

Issue

I can't insert a new line and tabs with sed

 cat /etc/login.conf | sed -e 's|:umask=022:|:umask=022:\\\n:charset=UTF-8:|g'

        :umask=022:\\\n\t\t:charset=UTF-8:\\\n\t\t:lang=en_US.UTF-8:

Solution

As some sed versions don't support \n insertion, you can try with literal $'\n' and $'\t' character :

cat /etc/login.conf | sed -e 's|:umask=022:|:umask=022:\'$'\n\t\t:charset=UTF-8:|g'


Answered By - SLePort
Answer Checked By - Gilberto Lyons (WPSolving Admin)