Sed unterminated`s command when attaching code to a block

This is the file that I would like to modify. I would like to add an entry to servers {.

eap-radius {

    # Section to specify multiple RADIUS servers.
    servers {

    }
}

Here is what I tried

sed -i '/servers {/a\
server-a {
            accounting = yes
            secret = 123456
            address = 127.0.0.1
            auth_port = 1812
            acct_port = 1813
}
' /etc/strongswan.d/charon/eap-radius.conf

sed: -e expression # 1, char 81: unterminated`s command

+4
source share
1 answer

I think you need to avoid new lines:

sed '/servers {/a\
        server-a {\
            accounting = yes\
            secret = 123456\
            address = 127.0.0.1\
            auth_port = 1812\
            acct_port = 1813\
        }
' ./test.txt

Results (I also added a bit tab server-a):

eap-radius {

    # Section to specify multiple RADIUS servers.
    servers {
        server-a {
            accounting = yes
            secret = 123456
            address = 127.0.0.1
            auth_port = 1812
            acct_port = 1813
        }

    }
}

Tested on Ubuntu 14.04.5 LTS, GNU bash version 4.3.11 (1) -release

0
source

Source: https://habr.com/ru/post/1689499/


All Articles