sed unterminated `s' command when attaching code to a block

Viewed 79

This is the file I would like to change. I would like to add an entry under servers {.

eap-radius {

    # Section to specify multiple RADIUS servers.
    servers {

    }
}

This is what I have 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

1 Answers

I think you need to escape new-lines:

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

The results are (I also tabbed a bit server-a block):

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

Related