这是我要更改的文件。我想在 servers {
下添加一个条目。
eap-radius {
# Section to specify multiple RADIUS servers.
servers {
}
}
这是我试过的
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
最佳答案
我认为你需要转义新行:
sed '/servers {/a\
server-a {\
accounting = yes\
secret = 123456\
address = 127.0.0.1\
auth_port = 1812\
acct_port = 1813\
}
' ./test.txt
结果是(我还标记了一点 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
}
}
}
在 Ubuntu 14.04.5 LTS、GNU bash 版本 4.3.11(1)-release 上测试
关于bash - 将代码附加到 block 时 sed 未终止 `s' 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47366311/