I'd liked to use the 'a' function of
For instance, I want to add "ListenAddress xx.xx.xxx.xxx" after the line that begins with "#ListenAddress" in a copy of sshd_config:
Using
Fine, as sed(1) reads:
But then:
Other incorrect variations:
sed
to append something after a given line in a file.For instance, I want to add "ListenAddress xx.xx.xxx.xxx" after the line that begins with "#ListenAddress" in a copy of sshd_config:
Using
sh
I do:
Rich (BB code):
# IP=xx.xx.xxx.xxx
# sed -E -i "" "/^#ListenAddress.*/aListenAddress $IP" new/sshd_config
sed: 1: "/^#ListenAddress.*/aLis ...": command a expects \ followed by text
Fine, as sed(1) reads:
[1addr]a\
text Write text to standard output immediately before each attempt to
read a line of input, whether by executing the "N" function or by
beginning a new cycle.
But then:
Code:
# sed -E -i "" "/^#ListenAddress.*/a\ListenAddress $IP" new/sshd_config
sed: 1: "/^#ListenAddress.*/a\Li ...": extra characters after \ at the end of a command
Other incorrect variations:
Code:
# sed -E -i "" "/^#ListenAddress.*/a\
> ListenAddress $IP" new/sshd_config
sed: 1: "/^#ListenAddress.*/aLis ...": command a expects \ followed by text
# sed -E -i "" "/^#ListenAddress.*/a\\ListenAddress $IP" new/sshd_config
sed: 1: "/^#ListenAddress.*/a\Li ...": extra characters after \ at the end of a command
# sed -E -i "" "/^#ListenAddress.*/a\\\
> ListenAddress $IP" new/sshd_config
sed: 1: "/^#ListenAddress.*/a\Li ...": extra characters after \ at the end of a command